fandango.log module¶
Contents
Description¶
Example of usage: class logged_class(Logger):
- def __init__(self,name,system):
- #parent must be also an instance of a Logger object self.call__init__(Logger,name,parent=system) pass
...
Example of logging: In [17]: import logging In [18]: l = logging.getLogger(“something”) In [19]: l.debug(“message”) In [20]: l.error(“message”) No handlers could be found for logger “something” In [21]: l.addHandler(logging.StreamHandler()) In [22]: l.error(“message”) message
fandango.logger submodule provides a default Logger instance and its info/debug/warning/error/trace methods directly available as module methods.
import fandango.log fandango.log.info(‘just a test’) fandango.Logger.INFO 2016-02-19 11:49:55.609 just a test
Classes¶
Logger¶
- class fandango.log.Logger(name='fandango.Logger', parent=None, format='%(levelname)-8s %(asctime)s %(name)s: %(message)s', use_tango=True, use_print=True, level='INFO', max_len=0)[source]¶
This class provides logging methods (debug,info,error,warning) to all classes inheriting it. To use it you must inherit from it and add it within your __init__ method:
class MyTangoDevice(Device_4Impl,Logger):
def __init__(self,cl, name):
PyTango.Device_4Impl.__init__(self,cl,name) self.call__init__(Logger,name,format=’%(levelname)-8s %(asctime)s %(name)s: %(message)s’)- Constructor arguments allow to customize the output format:
- name=’fandango.Logger’ #object name to appear at the beginning
- parent=None
- format=’%(levelname)-8s %(asctime)s %(name)s: %(message)s’ * use_tango=True #Use Tango Logger if available
- use_print=True #Use printouts instead of linux logger (use_tango will override this option)
- level=’INFO’ #default log level
- max_len=0 #max length of log strings
- setLevel(level)¶
This method allows to change the default logging level
raw autodoc¶
- class fandango.log.FakeLogger(header='', keep=False)[source]
This class just simulates a Logger using prints with date and header, it doesn’t allow any customization
- class fandango.log.InOutLogged(f)[source]
Bases: fandango.objects.Decorator
This class provides an easy way to trace whenever python enter/leaves a function.
- class fandango.log.Logger(name='fandango.Logger', parent=None, format='%(levelname)-8s %(asctime)s %(name)s: %(message)s', use_tango=True, use_print=True, level='INFO', max_len=0)[source]
Bases: fandango.objects.Object
This class provides logging methods (debug,info,error,warning) to all classes inheriting it. To use it you must inherit from it and add it within your __init__ method:
class MyTangoDevice(Device_4Impl,Logger):
def __init__(self,cl, name):
PyTango.Device_4Impl.__init__(self,cl,name) self.call__init__(Logger,name,format=’%(levelname)-8s %(asctime)s %(name)s: %(message)s’)- Constructor arguments allow to customize the output format:
- name=’fandango.Logger’ #object name to appear at the beginning
- parent=None
- format=’%(levelname)-8s %(asctime)s %(name)s: %(message)s’ * use_tango=True #Use Tango Logger if available
- use_print=True #Use printouts instead of linux logger (use_tango will override this option)
- level=’INFO’ #default log level
- max_len=0 #max length of log strings
- Debug = 10¶
- Error = 40¶
- Info = 20¶
- Warning = 30¶
- changeLogName(name)[source]
Change the log name.
- root_inited = True¶
- setLevel(level)
This method allows to change the default logging level
- setLevelAlias(alias, level)[source]
setLevelAlias(alias,level), allows to setup predefined levels for different tags
- setLogLevel(level)[source]
This method allows to change the default logging level
- setLogPrint(force)[source]
This method enables/disables a print to be executed for each log call
- fandango.log.except2str(e=None, max_len=600)[source]
- fandango.log.printerr(*args)[source]
- fandango.log.printf(*args)[source]
- fandango.log.printtest(obj, meth='', args=[], kwargs={})[source]
Executes a method providing a verbose output. For usage examples see fandango.device.FolderDS.FolderAPI.__test__()
- fandango.log.shortstr(s, max_len=144)[source]
- fandango.log.test2str(obj, meth='', args=[], kwargs={})[source]
Executes a method providing a verbose output. For usage examples see fandango.device.FolderDS.FolderAPI.__test__()