Add cron option to suppress logging to stdout#1
Open
mape2k wants to merge 2 commits intoMrBE4R:masterfrom
Open
Add cron option to suppress logging to stdout#1mape2k wants to merge 2 commits intoMrBE4R:masterfrom
mape2k wants to merge 2 commits intoMrBE4R:masterfrom
Conversation
MrBE4R
requested changes
Nov 1, 2019
Owner
MrBE4R
left a comment
There was a problem hiding this comment.
Great addition, I usually redirect stdout output to /dev/null in crontab.
Comment on lines
+21
to
+22
| if config is None: | ||
| logstdout('Initializing gitlab-ldap-sync failed.') |
Owner
There was a problem hiding this comment.
This should be within the else at the end of this script
Comment on lines
+11
to
18
| CRON = False | ||
|
|
||
| def logstdout(s): | ||
| if not CRON: | ||
| print(s) | ||
|
|
||
| if __name__ == "__main__": | ||
| print('Initializing gitlab-ldap-sync.') | ||
| config = None |
Owner
There was a problem hiding this comment.
We should add a global CRON in both logstdout and __main__ to ensure we use the same variable
Comment on lines
+24
to
+27
| logstdout('Initializing gitlab-ldap-sync successfull.') | ||
| if config['cron']: | ||
| CRON = True | ||
| logstdout('Updating logger configuration') |
Owner
There was a problem hiding this comment.
To be consitent this should be something like this :
CRON = config['cron']
logstdout('Initializing gitlab-ldap-sync successfull.')
logstdout('Updating logger configuration')
Comment on lines
+36
to
+39
| if config['cron'] and config['log']: | ||
| console = logging.StreamHandler() | ||
| console.setLevel(logging.ERROR) | ||
| logging.getLogger('').addHandler(console) |
Owner
There was a problem hiding this comment.
I don't think we need this part. We already suppress "print" logs and you can set the log level in config.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello MrBE4R,
this commit add a new option to suppress logging to stdout if script is used in cronjobs.