python logging
#!/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 ""