surok/surok/logger.py
Denis Zheleztsov 3eba2697e6 closes #3
2016-11-11 21:14:36 +03:00

37 lines
656 B
Python

import sys
from time import time
def make_message(message):
cur_time = str(time())
m = '[' + cur_time + '] ' + message['level'] + ': ' + message['raw'] + "\n"
return m
def info(message):
req = {'level': 'INFO', 'raw': message}
m = make_message(req)
sys.stdout.write(m)
def warning(message):
req = {'level': 'WARNING', 'raw': message}
m = make_message(req)
sys.stderr.write(m)
def error(message):
req = {'level': 'ERROR', 'raw': message}
m = make_message(req)
sys.stderr.write(m)
def debug(message):
req = {'level': 'DEBUG', 'raw': message}
m = make_message(req)
sys.stderr.write(m)