Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import inspect
- logging_function = """
- def print_{}(msg, indent=0):
- print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + " (" + inspect.stack()[1].function + ") {}: -" + " "*indent*2 + " " + msg)
- """
- for loglevel in ["DEBUG ", "INFO ", "WARN ", "ERROR ", "FATAL "]:
- exec(logging_function.format(loglevel.lower().strip(), loglevel))
- print_info("This is an info message", 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement