Martín Santillán Cooper commited on
Commit
1a38959
1 Parent(s): 93e42f8

add file logger

Browse files
Files changed (2) hide show
  1. .gitignore +2 -1
  2. logger.py +8 -3
.gitignore CHANGED
@@ -2,4 +2,5 @@
2
  .env
3
  parse.py
4
  unparsed_catalog.json
5
- __pycache__
 
 
2
  .env
3
  parse.py
4
  unparsed_catalog.json
5
+ __pycache__
6
+ logs
logger.py CHANGED
@@ -2,6 +2,11 @@ import logging
2
 
3
  logger = logging.getLogger('demo')
4
  logger.setLevel(logging.DEBUG)
5
- handler = logging.StreamHandler()
6
- handler.setLevel(logging.DEBUG)
7
- logger.addHandler(handler)
 
 
 
 
 
 
2
 
3
  logger = logging.getLogger('demo')
4
  logger.setLevel(logging.DEBUG)
5
+
6
+ stream_handler = logging.StreamHandler()
7
+ stream_handler.setLevel(logging.DEBUG)
8
+ logger.addHandler(stream_handler)
9
+
10
+ file_handler = logging.FileHandler('logs')
11
+ file_handler.setFormatter(logging.Formatter("%(asctime)s - %(filename)s:%(lineno)d - %(message)s", datefmt="%Y-%m-%d %H:%M:%S"))
12
+ logger.addHandler(file_handler)