-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLog.py
More file actions
36 lines (28 loc) · 999 Bytes
/
Log.py
File metadata and controls
36 lines (28 loc) · 999 Bytes
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
33
34
35
36
# Created by Zachary Andrews
# Github: ZachAndrews98
import logging
import logging.handlers
LOG_FILENAME = './.logs/log.out'
ERROR_FILENAME = './.logs/error.out'
MAX_BYTES = 50000 * 10 ^ 8
# creates general log
logger = logging.getLogger('General')
logger.setLevel(logging.DEBUG)
handler = logging.handlers.RotatingFileHandler(
LOG_FILENAME, maxBytes=MAX_BYTES, backupCount=5)
logger.addHandler(handler)
# creates error log
error_logger = logging.getLogger('Error')
error_logger.setLevel(logging.ERROR)
error_handler = logging.handlers.RotatingFileHandler(
ERROR_FILENAME, maxBytes=MAX_BYTES, backupCount=5)
error_logger.addHandler(error_handler)
def log_info(info):
info = info.replace('\n', ' ')
logger.info(' INFO- ' + info)
def log_debug(debug):
debug = debug.replace('\n', ' ')
logger.debug('DEBUG- ' + debug)
def log_error(Exception):
logger.debug('DEBUG- ERROR OCCURRED, CHECK ERROR LOG')
error_logger.error('\t\t\t\t\t\t\t\t==Error==', exc_info=True)