Friday, March 24, 2017

pylint, python logger


pylint --disable=R,C,W,I,E,F test.py --msg-template='{msg_id}:{line:3d},{column}: {obj}: {msg}' --disable=import-error --rcfile ./to-path/.pylintrc


import logging
import sys

root = logging.getLogger()
root.setLevel(logging.DEBUG)

fo= open("/Users/sadatravu/Surya/py_scripts/text.log", "w")
ch= logging.StreamHandler(fo)
#ch = logging.StreamHandler(sys.stdout) # this is for logging into stdout
ch.setLevel(logging.DEBUG)

formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)

root.addHandler(ch)

def main():
    for i in range(10):
       logging.debug("message [%d]"%i)

main()