Add class for logging in log file
This commit is contained in:
		
							
								
								
									
										28
									
								
								radicale/log.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								radicale/log.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
|  | ||||
| import sys | ||||
| import logging | ||||
|  | ||||
| from radicale import config | ||||
|  | ||||
| LEVELS = {	'debug': logging.DEBUG, | ||||
| 			'info': logging.INFO, | ||||
| 			'warning': logging.WARNING, | ||||
| 			'error': logging.ERROR, | ||||
| 			'critical': logging.CRITICAL} | ||||
|  | ||||
| level=LEVELS.get(config.get("logging", "level"), logging.NOTSET) | ||||
|  | ||||
| logger=logging.getLogger("radicale") | ||||
| logger.setLevel(level=level) | ||||
|  | ||||
| handler=logging.FileHandler(config.get("logging", "file")) | ||||
| handler.setLevel(level=level) | ||||
| 		 | ||||
| formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") | ||||
| 		 | ||||
| handler.setFormatter(formatter) | ||||
| 		 | ||||
| logger.addHandler(handler) | ||||
|  | ||||
| sys.modules[__name__] = logger | ||||
		Reference in New Issue
	
	Block a user
	 System User
					System User