fandango.log module

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
changeLogName(name)[source]

Change the log name.

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

LogFilter

class fandango.log.LogFilter(level)[source]

FakeLogger

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

InOutLogged

class fandango.log.InOutLogged(f)[source]

This class provides an easy way to trace whenever python enter/leaves a function.

Functions

printf

fandango.log.printf(*args)[source]

except2str

fandango.log.except2str(e=None, max_len=600)[source]

printerr

fandango.log.printerr(*args)[source]

printtest

fandango.log.printtest(obj, meth='', args=[], kwargs={})[source]

Executes a method providing a verbose output. For usage examples see fandango.device.FolderDS.FolderAPI.__test__()

shortstr

fandango.log.shortstr(s, max_len=144)[source]

test2str

fandango.log.test2str(obj, meth='', args=[], kwargs={})[source]

Executes a method providing a verbose output. For usage examples see fandango.device.FolderDS.FolderAPI.__test__()


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

debug(s)[source]
error(s)[source]
info(s)[source]
setLogLevel(s)[source]
trace(s)[source]
warning(s)[source]
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.LogFilter(level)[source]

Bases: logging.Filter

filter(record)[source]
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
addChild(child)[source]
addLogHandler(handler)[source]
changeLogName(name)[source]

Change the log name.

copyLogHandlers(other)[source]
debug(msg, *args, **kw)[source]
delChild(child)[source]
deprecated(msg, *args, **kw)[source]
error(msg, *args, **kw)[source]
flushOutput()[source]
getChildren()[source]
getLogLevel(alias=None)[source]
getParent()[source]
getRootLog()[source]
getTangoLog()[source]
getTimeString(t=None)[source]
info(msg, *args, **kw)[source]
initRoot(_format='%(threadName)-12s %(levelname)-8s %(asctime)s %(name)s: %(message)s')[source]
logPrint(prio, msg)[source]
output(msg, *args, **kw)[source]
root_inited = True
sendToStream(msg, level, prio, *args, **kw)[source]
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

syncLog()[source]
trace(msg, *args, **kw)[source]
warning(msg, *args, **kw)[source]
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__()