Created
January 11, 2016 07:05
-
-
Save sunilnandihalli/11ac7ab6766811ccc0bd to your computer and use it in GitHub Desktop.
This file contains 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
class logger: | |
def __init__(self,fname=None,copy_to_stdout=True): | |
self.copy_to_stdout=copy_to_stdout | |
if fname: | |
x=datetime.datetime.now() | |
self.fd = open('%s-%04d%02d%02d%02d%02d.log'%(fname,x.year,x.month,x.day,x.hour,x.minute),'w') | |
else: | |
self.copy_to_stdout = False | |
self.fd = sys.stdout | |
def log(self,*s): | |
print >>self.fd,datetime.datetime.utcnow(),s | |
if self.copy_to_stdout: | |
print datetime.datetime.utcnow(),s | |
self.fd.flush() | |
info_log = logger('info.log') | |
failed_honest_models = logger('failed_honest_models.log') | |
failed_smaato_models = logger('failed_smaato_models.log') | |
not_enough_data_tuples = logger('not_enough_data.log') | |
processed_data = logger('processed_data.log') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment