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 14 - (view) (download) (as text)

1 : agomez 10 #
2 :     # BonFIRE Virtual Clusters on Federated Clouds Demonstration Kit
3 :     #
4 :     # Copyright (c) Fundacion Centro Tecnologico de Supercomputacion de Galicia 2012
5 :     #
6 : agomez 14 # License Apache Software
7 : agomez 10 #
8 :     # The research leading to these results has received funding from
9 :     # the European Community's Seventh Framework Programme (FP7/2007-2013)
10 :     # under agreement number 257386
11 :     #
12 :     # This software is provided with ABSOLUTELY NO WARRANTY
13 :     #
14 :     # -*- coding: utf-8 -*-
15 :     import logging.handlers
16 :    
17 :     DEFAULT_FORMAT = "%(asctime)s - %(module)s:%(lineno)d - %(levelname)s - %(message)s"
18 :    
19 :     class NullHandler(logging.Handler):
20 :     def emit(self, record):
21 :     pass
22 :    
23 :     def configure(logfile = None, debug = False, console = False):
24 :     log.setLevel(logging.DEBUG)
25 :     formatter = logging.Formatter(DEFAULT_FORMAT)
26 :     if logfile != None:
27 :     rotate = logging.handlers.RotatingFileHandler(logfile,maxBytes=1048576,backupCount=2)
28 :     rotate.setFormatter(formatter)
29 :     rotate.setLevel(logging.INFO)
30 :     if debug:
31 :     rotate.setLevel(logging.DEBUG)
32 :     log.addHandler(rotate)
33 :    
34 :     if console:
35 :     cli = logging.StreamHandler()
36 :     cli.setFormatter(formatter)
37 :     cli.setLevel(logging.INFO)
38 :     if debug:
39 :     cli.setLevel(logging.DEBUG)
40 :     log.addHandler(cli)
41 :    
42 :    
43 :    
44 :     log = logging.getLogger()
45 :     log.addHandler(NullHandler())

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

Powered By FusionForge