-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloggingExample.py
More file actions
28 lines (25 loc) · 777 Bytes
/
Copy pathloggingExample.py
File metadata and controls
28 lines (25 loc) · 777 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
#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: maic
#
# Created: 25/01/2012
# Copyright: (c) maic 2012
# Licence: <your licence>
#-------------------------------------------------------------------------------
#!/usr/bin/env python
import logging
import os
logDir = os.path.dirname(__file__)+'/logs'
logger = logging.getLogger('loggingExample')
logger.setLevel(logging.DEBUG)
hdlr = logging.FileHandler(logDir+'/error.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
def main():
logger.info("This is some information")
logger.error("This is an error")
if __name__ == '__main__':
main()