Created
July 21, 2020 18:17
-
-
Save sfdc-afraley/0780e431de04aeeb78541909c417dffb to your computer and use it in GitHub Desktop.
This file contains 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
""" Example using the Python logger """ | |
import logging | |
def main(): | |
""" MAIN """ | |
init_logger(debug=True) | |
logging.info('Hey this message is important and is always outputted') | |
some_var = 123545 | |
logging.debug('This is only important when debugging') | |
logging.debug('Here is the value of some variable: %s', some_var) | |
logging.error('SOMETHING WENT WRONG ALERT ALL THE THINGS!') | |
def init_logger(debug=False): | |
""" Start the python logger """ | |
log_format = '%(asctime)s %(levelname)-8s %(message)s' | |
if debug: | |
level = logging.DEBUG | |
else: | |
level = logging.INFO | |
logging.basicConfig(level=level, format=log_format) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment