loggers¶
Data:
List of instantiated loggers, used in |
Functions:
|
Initialize a logger |
- _LOGGERS = []¶
List of instantiated loggers, used in
init_logger()
to return existing loggers without modification
- init_logger(instance=None, module_name=None, class_name=None, object_name=None) logging.Logger [source]¶
Initialize a logger
Loggers are created such that…
There is one logger per module (eg. all gpio objects will log to hardware.gpio)
If the passed object has a
name
attribute, that name will be prefixed to its log messages in the fileThe loglevel for the file handler and the stdout is determined by
prefs.get('LOGLEVEL')
, and if none is providedWARNING
is used by defaultlogs are rotated according to
prefs.get('LOGSIZE')
(in bytes) andprefs.get('LOGNUM')
(number of backups ofprefs.get('LOGSIZE')
to cycle through)
Logs are stored in
prefs.get('LOGDIR')
, and are formatted like:"%(asctime)s - %(name)s - %(levelname)s : %(message)s"
Loggers can be initialized either by passing an object to the first
instance
argument, or by specifying any ofmodule_name
,class_name
, orobject_name
(at least one must be specified) which are combined with periods likemodule.class_name.object_name
- Parameters
instance – The object that we are creating a logger for! if None, at least one of
module, class_name, or object_name
must be passedmodule_name (None, str) – If no
instance
passed, the module name to create a logger forclass_name (None, str) – If no
instance
passed, the class name to create a logger forobject_name (None, str) – If no
instance
passed, the object name/id to create a logger for
- Returns
logging.logger