PYTHON

python logging

고요한하늘... 2012. 11. 7. 13:17

#!/usr/bin/env python

#-*- coding: utf8 -*-

from sys import stderr, stdout

from time import gmtime, strftime


verbose=0


def error( **message ):

        if verbose > 0 :

                local_time=strftime("%a, %d %b %Y %H:%M:%S", gmtime());

                print "[" +local_time + "] ",

                for key, val in message.items():

                        if len(val.rstrip()) > 80 :     print key.rstrip()+" : "+val.rstrip()[:80] + "..., ",

                        else:                           print key.rstrip()+" : "+val.rstrip(),

                print ""


def warn ( **message ):

        if verbose > 1 :

                local_time=strftime("%a, %d %b %Y %H:%M:%S", gmtime());

                print "[" +local_time + "] ",

                for key, val in message.items():

                        if len(val.rstrip()) > 80 :     print key.rstrip()+" : "+val.rstrip()[:80] + "..., ",

                        else:                           print key.rstrip()+" : "+val.rstrip(),

                print ""


def info ( **message ):

        if verbose > 2 :

                local_time=strftime("%a, %d %b %Y %H:%M:%S", gmtime());

                print "[" +local_time + "] ",

                for key, val in message.items():

                        if len(val.rstrip()) > 80 :     print key.rstrip()+" : "+val.rstrip()[:80] + "..., ",

                        else:                           print key.rstrip()+" : "+val.rstrip(),

                print ""



'PYTHON' 카테고리의 다른 글

python option  (0) 2012.11.07
python option  (0) 2012.11.07
undefined symbol: Py_InitModule4TraceRefs_64   (0) 2011.05.17
파이선 파일 관련 함수  (0) 2008.09.18
파이선 디버깅  (0) 2008.03.24