Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add log keeping functionality #49

Merged
merged 2 commits into from
Mar 6, 2024
Merged

Add log keeping functionality #49

merged 2 commits into from
Mar 6, 2024

Conversation

panosfol
Copy link
Collaborator

@panosfol panosfol commented Feb 28, 2024

This PR is unfinished, i.e doesn't use the email interface, it needs #47 to be resolved first.
This closes #46

Copy link
Contributor

@charmitro charmitro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a voice-call with @panosfol we discussed and designed the following:

  1. Do not show the user output from execve
  2. Pipe all execve output for log file
  3. Add pr_{debug|info|error|warn}_fd macros that will write both to file and STDOUT/STDERR

@panosfol If I forgot anything please append.

@panosfol panosfol changed the title Email refactor Add log keeping functionality Feb 28, 2024
src/config.c Outdated Show resolved Hide resolved
include/config.h Outdated Show resolved Hide resolved
src/config.c Outdated Show resolved Hide resolved
src/config.c Outdated Show resolved Hide resolved
src/config.c Outdated Show resolved Hide resolved
src/config.c Outdated Show resolved Hide resolved
src/postgres.c Outdated Show resolved Hide resolved
src/config.c Show resolved Hide resolved
Copy link
Contributor

@charmitro charmitro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First round.

include/log.h Outdated Show resolved Hide resolved
src/log.c Outdated Show resolved Hide resolved
src/log.c Outdated Show resolved Hide resolved
src/log.c Outdated Show resolved Hide resolved
src/log.c Outdated Show resolved Hide resolved
include/util.h Outdated Show resolved Hide resolved
src/postgres.c Outdated Show resolved Hide resolved
include/log.h Show resolved Hide resolved
src/config.c Show resolved Hide resolved
src/util.c Outdated Show resolved Hide resolved
src/util.c Outdated Show resolved Hide resolved
This commit contains the necessary changes for log keeping as well as
a new section [general] for the `.ini` file with `log_filepath` as a new field.

Changelog:

config.h: add [general] section and `log_filepath` field
	& a new struct to hold the value of the `.ini` file

config.c: add parsing of the new section

log.h:
	- add a new macro similar to pr_{debug|info|error|warn} that writes
	- both to the log file and the STDOUT/STDERR
	- add macro for `LOG_FILEPATH` and `LOG_FILENAME`
	- add `construct_log_filepath` function, which is responsible for
	creating and checking the necessary permissions for log-keeping
	directory.
	- add `construct_log_filename` function that creates the name of the
	log file with the format `cncDDMMYY_HHMMSS.log`.

util.h:
	- add `mkdir_p` function to create iteratively the parent directories
	of a user defined path.
	- add `cnc_strdup` function that calls `strdup` and checks if the call
	was successful.

config.c: change `initialize_config` to construct the log file utilizing
	the new functions added to `log.h`

cnc.c: add error handling if `initialize_config` fails to open the log file

cnc_tests.c: add 2 tests for the new field

Signed-off-by: Panagiotis Foliadis <pfoliadis@hotmail.com>
Utilize the `log` interface to create and append to a log file the
results of the `pg_replicate`.

postgres.c: util.c: utilize the new macro for appending to the log file
		    remove the usage of variables around constructing
		    an email body

postgres.h: add `PG_DUMP_FILE` macro and change the declaration
	of `construct_pg` function to return an error code in
	case of not being able to open the `.log` file

util.h: remove the unecessary arguments for the email body and size

Signed-off-by: Panagiotis Foliadis <pfoliadis@hotmail.com>
@charmitro
Copy link
Contributor

Thanks! LGTM, merging.

This means that #47 is unblocked and we can move forward with the implementation.

@charmitro charmitro merged commit 9444902 into master Mar 6, 2024
4 checks passed
@charmitro charmitro deleted the email-refactor branch March 6, 2024 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance Output Handling by Piping STDOUT/STDERR to a File
2 participants