forked from bin2415/ste-GAN-ography2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.py
32 lines (24 loc) · 748 Bytes
/
logger.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import logging
import subprocess
import sys
import os
LOG_FILE_NAME = 'main.log'
formatter = logging.Formatter('%(asctime)s [%(levelname)s] ' "\t" '%(message)s')
log_file_path = LOG_FILE_NAME
file_log = logging.FileHandler(log_file_path)
file_log.setFormatter(formatter)
stdout = logging.StreamHandler(sys.stdout)
stdout.setFormatter(formatter)
logger = logging.getLogger('stego')
logger.setLevel(logging.DEBUG)
logger.addHandler(file_log)
logger.addHandler(stdout)
def log(message):
# decorator for logging what function is doing
def wrapper(func):
def execute(*args, **kwargs):
logger.debug(message)
result = func(*args, **kwargs)
return result
return execute
return wrapper