root/tags/v1.0/debug.py

Revision 27, 1.0 KB (checked in by daedalus, 4 years ago)

* Added 'authoritarian' mode, which allows you permit/deny each and every command

that will be issued to a remote device. Designed for testing new change scripts.

* Added a 'command_timeout' parameter to Command Provisioners, so you can override

the default command timeout of 300 seconds by setting an attribute in the config
file

* Added proper handling of the 'onfail: continue' idea. You can now specify that

if a change fails, and it is a pre-requisite for some other change, processing
will continue despite the failure.

* Added the onfail: retry feature. If a change fails, you can specify that it should

be retried. You can also set a max number of retries. The default is 3.

Line 
1# $Id$
2#
3##COPYRIGHT##
4
5__version__ = '$Revision: 1.28 $'
6
7import os
8import os.path
9import threading
10import logging
11import logging.handlers
12import sys
13
14#FORMAT = "%(asctime)s %(levelname)7s [%(thread)x] (%(module)s) %(message)s"
15#FORMAT = "%(asctime)s %(levelno)2s (%(module)s) %(message)s"       
16FORMAT = "%(asctime)s %(levelname)7s: %(message)s"
17formatter = logging.Formatter(FORMAT, '%Y-%m-%d %H:%M:%S')
18
19stdoutHandler = logging.StreamHandler(sys.stdout)
20stdoutHandler.setFormatter(formatter)
21
22class LocalLogger(logging.Logger):
23   
24    def __init__(self, name):
25        level = logging.INFO
26        logging.Logger.__init__(self, name, level)
27        self.addHandler(stdoutHandler)
28        return
29    pass
30
31def add_file_handler(filename):
32    handler = logging.handlers.RotatingFileHandler(filename=filename, maxBytes=10e6, backupCount=10)
33    handler.setFormatter(formatter)
34    log = logging.getLogger('modipy')
35    log.addHandler(handler)
36   
37logging.setLoggerClass(LocalLogger)
38
Note: See TracBrowser for help on using the browser.