-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.py
46 lines (31 loc) · 1.12 KB
/
test2.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import logging
# Configure the root logger
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
# Get the root logger
logger = logging.getLogger()
# Log messages
# logger.debug("This is a DEBUG message.") # Won't appear (INFO level is higher)
# logger.info("This is an INFO message.") # Will appear
# logger.warning("This is a WARNING message.") # Will appear
logger.debug("This is a debug message.")
logger.info("This is an info message.")
logger.warning("This is a warning message.")
logger.error("This is an error message.")
logger.critical("This is a critical message.")
import os
import sys
logging_str = "%(levelname)s: %(module)s : line no> %(lineno)d : %(message)s"
log_dir = "logs"
log_filepath = os.path.join(log_dir,"running_logs.log")
os.makedirs(log_dir, exist_ok=True)
logging.basicConfig(
level= logging.INFO,
format= logging_str,
handlers=[
logging.FileHandler(log_filepath),
logging.StreamHandler(sys.stdout)
]
)
logger2 = logging.getLogger("cnnClassifierLogger1")
logger2.info("Welcome to cnnClassifier")
# 'print(str(logging.basicConfig))