Revision 14 -
(download)
(as text)
(annotate)
Mon Oct 8 09:46:28 2012 UTC
(11 years, 10 months ago)
by agomez File size: 1285 byte(s)
New license from GPL to Apache
Cleaning some files that are not used.
#
# BonFIRE Virtual Clusters on Federated Clouds Demonstration Kit
#
# Copyright (c) Fundacion Centro Tecnologico de Supercomputacion de Galicia 2012
#
# License Apache Software
#
# The research leading to these results has received funding from
# the European Community's Seventh Framework Programme (FP7/2007-2013)
# under agreement number 257386
#
# This software is provided with ABSOLUTELY NO WARRANTY
#
# -*- coding: utf-8 -*-
import logging.handlers
DEFAULT_FORMAT = "%(asctime)s - %(module)s:%(lineno)d - %(levelname)s - %(message)s"
class NullHandler(logging.Handler):
def emit(self, record):
pass
def configure(logfile = None, debug = False, console = False):
log.setLevel(logging.DEBUG)
formatter = logging.Formatter(DEFAULT_FORMAT)
if logfile != None:
rotate = logging.handlers.RotatingFileHandler(logfile,maxBytes=1048576,backupCount=2)
rotate.setFormatter(formatter)
rotate.setLevel(logging.INFO)
if debug:
rotate.setLevel(logging.DEBUG)
log.addHandler(rotate)
if console:
cli = logging.StreamHandler()
cli.setFormatter(formatter)
cli.setLevel(logging.INFO)
if debug:
cli.setLevel(logging.DEBUG)
log.addHandler(cli)
log = logging.getLogger()
log.addHandler(NullHandler())