Skip to content

Instantly share code, notes, and snippets.

@mottosso
Created October 22, 2014 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mottosso/6158ffeac47cc150d070 to your computer and use it in GitHub Desktop.
Save mottosso/6158ffeac47cc150d070 to your computer and use it in GitHub Desktop.
Logging in The Foundy Modo
#python
import logging
# Pick up the "root" logger
log = logging.getLogger()
# In addition, Modo doesn't come with a handler; handlers
# are the objects actually performing any printing. So we'll
# add a vanilla handler that simply prints what the user asks
# along with a prefix of which level the message is at.
formatter = logging.Formatter("%(levelname)s %(message)s")
# "StreamHandler" just means it prints to the console (i.e.
# stdout). Alternative handlers may log to files or across
# a network.
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(formatter)
log.addHandler(stream_handler)
# The root logger in Modo has been initialised at a
# level above INFO, which means it will only print
# messages in the WARNING-CRITICAL range
log.setLevel(logging.INFO)
# Finally, at the INFO level, print something.
log.info("Logging works!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment