#! /usr/bin/env python import sys import traceback, time import StringIO from mid_mail import MidMail midmail = MidMail() class Logger(object): def __init__(self, name="log", path="/data/xce/zhaohui.tang/log", type="hourly"): self.name = name self.path = path self.type = type if type == "hourly": self.log_file = open( path + "/" + name + "." + time.strftime("%Y-%m-%d-%H"), "a") elif type == "minutely": self.log_file = open( path + "/" + name + "." + time.strftime("%Y-%m-%d-%H-%M"), "a") def info(self, str): # log and print print str self.log_file.write(str + "\n") def log(self, str): self.log_file.write(str + "\n")