示例#1
0
文件: panda.py 项目: drwsrwsrwx/Panda
 def warning(self, logMsg, logType='warn', verbose=True, write=True, logFile=self.logFile):
     from time import strftime as s, gmtime as g
     log = "%s %s Warning: %s" % (s(self.strf, g()), self.types[logType], logMsg)
     if self.verbose and verbose:
         print log
     if self.write and write:
         lf = open(logFile, "a")
         lf.write(log+"\n")
         lf.close()
示例#2
0
 def error(self, logMsg, logType='error', verbose=True, write=True):
     from time import strftime as s, gmtime as g
     log = "%s %s Error: %s" % (s(self.strf, g()), self.types[logType], logMsg)
     if self.verbose and verbose:
         print log
     if self.write and write:
         lf = open(self.logFile, "a")
         lf.write(log+"\n")
         lf.close()
示例#3
0
 def log(self, logMsg, logType='info', write=True):
     from time import strftime as s, gmtime as g
     log = "%s %s %s" % (s(self.strf, g()), self.types[logType], logMsg)
     if self.verbose:
         print log
     if self.write:
         if write:
             lf = open(self.logFile, "a")
             lf.write(log + "\n")
             lf.close()
示例#4
0
def logger(logMsg,
           logType="info",
           logFile="panda.log",
           verbose=True,
           write=False):
    from time import strftime as s, gmtime as g
    strf = "[%Y-%M-%d %H:%M%:%S]"
    logTypes = {"error": "[!]", "info": "[-]", "plus": "[+]"}
    log = "%s %s %s" % (s(strf, g()), logTypes[logType], logMsg)
    if verbose:
        print log
    if write:
        lf = open(logFile, "a")
        lf.write(log + "\n")
        lf.close()