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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (download) (as text) (annotate)
Fri Aug 31 10:40:38 2012 UTC (11 years, 9 months ago) by agomez
File size: 1283 byte(s)
Corrected minor error in license text
Powerpoint presentation to show how to use the software (also in PDF).
#
# BonFIRE Virtual Clusters on Federated Clouds Demonstration Kit
#
# Copyright (c) Fundacion Centro Tecnologico de Supercomputacion de Galicia 2012
# 
# License GPL Version 3
#
# 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())

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

Powered By FusionForge