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

Implement a verbosity system and use the logging module #1

Open
mbelmadani opened this issue Aug 16, 2016 · 0 comments
Open

Implement a verbosity system and use the logging module #1

mbelmadani opened this issue Aug 16, 2016 · 0 comments

Comments

@mbelmadani
Copy link
Owner

mbelmadani commented Aug 16, 2016

Standard output (messages) writing is currently used inconsistently (for example, sometimes using sys.write(), others with print() ).

  1. Every message or result specifc output (like the output pareto front, or motif statistics) should be using print() function. Other messages should use the python 'logging' module. Logger.info() for messages that are expected, Logger.critical() when the program errors and terminates, and Logger.warning( ) for anything else.

  2. At the same time, add a check for a verbosity level for each Logger and print. Having the verbosity as a string would allow more flexibility to the user. An idea:

i = info
w = warning
s = stats
r = results
d = debug - Also print the source location of the message

The user provides a string with these tags (e.g. "isr" for everything except warnings) and logging is only done for those in the string. Critical level messages are always printed, unless there's a good reason not to.

Logger should be configured as:

import logging
if "l" in options.verbosity:
    FORMAT = '[%(filename)s:%(lineno)s - %(funcName)20s() ] %(asctime)15s - %(levelname)s : %(message)s'
else:
    FORMAT = '%(asctime)15s - %(levelname)s : %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger(__name__)

and messages logged with:

if` "w" in options.verbosity:
    logger.warning("The warning message")

This change should not be made for standalone scripts, this is only for motifgp.py and its classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant