Пример #1
0
 def test_016_file_defaults(self):
     """
     Test default logging level for file
     """
     rmlog()
     Logger.addFileLogger({"filename": LOGFILE})
     self.assertEqual(logging.INFO, logging.getLogger().handlers[1].level)
Пример #2
0
 def test_015_file_misconfig(self):
     """
     Test misconfiguration
     """
     rmlog()
     with self.assertRaises(RuntimeError):
         Logger.addFileLogger({
             "filename_": LOGFILE,
             "level": logging.DEBUG,
             "format": "json"
         })
Пример #3
0
print("\n\nFile Contents:\n")
with open(LOGPATH) as f:
    print(f.read())

os.unlink(LOGPATH)

#
# 6. Lets add another log-file
#
print("\n6. Reconfiguring...\n")
fileSpecs = [{"filename": LOGFILE, "level": logging.DEBUG, "format": "json"}]
Logger.init(LOGDIR, termSpecs=termSpecs, fileSpecs=fileSpecs)

fileSpecs2 = {"filename": LOGFILE2, "level": logging.INFO}
Logger.addFileLogger(fileSpecs2)

logging.info("2 Files!")

print("\n\nFile Contents 1:\n")
with open(LOGPATH) as f:
    print(f.read())

os.unlink(LOGPATH)

print("\n\nFile Contents 2:\n")
with open(LOGPATH2) as f:
    print(f.read())

os.unlink(LOGPATH2)