Log In | Get Help   
Home My Page Projects Code Snippets Project Openings BonFIRE VCOC Demonstration Kit
Summary Activity SCM Files Wiki
[bonfiredemokit] Annotation of /virt-cluster/vc/logger.py
[bonfiredemokit] / virt-cluster / vc / logger.py Repository:
ViewVC logotype

Annotation of /virt-cluster/vc/logger.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download) (as text)

1 : agomez 1 # -*- coding: utf-8 -*-
2 :     import logging.handlers
3 :    
4 :     DEFAULT_FORMAT = "%(asctime)s - %(module)s:%(lineno)d - %(levelname)s - %(message)s"
5 :    
6 :     class NullHandler(logging.Handler):
7 :     def emit(self, record):
8 :     pass
9 :    
10 :     def configure(logfile = None, debug = False, console = False):
11 :     log.setLevel(logging.DEBUG)
12 :     formatter = logging.Formatter(DEFAULT_FORMAT)
13 :     if logfile != None:
14 :     rotate = logging.handlers.RotatingFileHandler(logfile,maxBytes=1048576,backupCount=2)
15 :     rotate.setFormatter(formatter)
16 :     rotate.setLevel(logging.INFO)
17 :     if debug:
18 :     rotate.setLevel(logging.DEBUG)
19 :     log.addHandler(rotate)
20 :    
21 :     if console:
22 :     cli = logging.StreamHandler()
23 :     cli.setFormatter(formatter)
24 :     cli.setLevel(logging.INFO)
25 :     if debug:
26 :     cli.setLevel(logging.DEBUG)
27 :     log.addHandler(cli)
28 :    
29 :    
30 :    
31 :     log = logging.getLogger()
32 :     log.addHandler(NullHandler())

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge