Created
September 24, 2015 09:59
-
-
Save tomotaka/6dc5001e7f2cd9ff8256 to your computer and use it in GitHub Desktop.
stdout python logging sample
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
# -*- coding: utf-8 -*- | |
import logging | |
import sys | |
def main(): | |
logger = logging.getLogger(__name__) | |
logger.setLevel(logging.DEBUG) | |
handler = logging.StreamHandler(sys.stdout) | |
formatter = logging.Formatter('[%(levelname)s] %(message)s (%(filename)s:%(lineno)s)') | |
handler.setFormatter(formatter) | |
logger.addHandler(handler) | |
logger.debug('hoge') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment