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

fix logger initialization #1316

Merged
merged 1 commit into from
Jan 25, 2018
Merged

fix logger initialization #1316

merged 1 commit into from
Jan 25, 2018

Conversation

gyorb
Copy link
Contributor

@gyorb gyorb commented Jan 24, 2018

The global LOG should be initialized only after the setup_logger
call which reads up the log config.

If the LOG is initialized at module import time it will use the
default Python logging config. By default this will print the
messages to the standard output which might not be a problem.

Some log messages might go to the wrong place (stdout) before the
logging config is read up in setup_logger if the default setting
in the log config forwards the log messages not to the stdout.

@gyorb gyorb requested a review from csordasmarton January 24, 2018 10:45
logger.setup_logger(args.verbose)
global LOG
Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn't we create a separate function for these steps at the top of the file?
E.g.:

def init_logger(log_level):
  logger.setup_logger(log_level)
  global LOG
  LOG = logger.get_logger('system')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@csordasmarton csordasmarton added bugfix 🔨 CLI 💻 Related to the command-line interface, such as the cmd, store, etc. commands labels Jan 24, 2018
@csordasmarton csordasmarton added this to the release 6.5 milestone Jan 24, 2018
The global LOG should be initialized only after the setup_logger
call which reads up the log config.

If the LOG is initialized at module import time it will use the
default Python logging config. By default this will print the
messages to the standard output which might not be a problem.

Some log messages might go to the wrong place (stdout) before the
logging config is read up in setup_logger if the default setting
in the log config forwards the log messages not to the stdout.
@whisperity whisperity added the dev env ⛑️ Development environment label Jan 24, 2018
@csordasmarton csordasmarton merged commit 02b70fe into Ericsson:master Jan 25, 2018
@gyorb gyorb deleted the fix-logging branch May 18, 2018 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix 🔨 CLI 💻 Related to the command-line interface, such as the cmd, store, etc. commands dev env ⛑️ Development environment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants