hio.help.ogling
hio.help.ogling module
Provides python stdlib logging module support
Module Contents
Classes
Olgery instances retreive and configure loggers from global logging facility |
Functions
|
Initialize the ogler global instance once |
|
Context manager wrapper Ogler instances. |
- hio.help.ogling.initOgler(level=logging.CRITICAL, **kwa)[source]
Initialize the ogler global instance once Usage:
# At top level of module in project # assign ogler as module global instance availabe at modulename.ogler ogler = hio.help.ogling.initOgler()
# module is mypackage.help then ogler at mypackage.help.ogler
Critical is most severe to restrict logging by default
- Parameters
None (force is Boolean True is to force reinit even if global ogler is not) –
level (level is default logging) –
This should be called in package .__init__ to insure that global ogler is defined by default. Users may then reset level and reopen log file if need be before calling ogler.getLoggers()
- hio.help.ogling.openOgler(cls=None, name='test', temp=True, **kwa)[source]
Context manager wrapper Ogler instances. Defaults to temporary file logs. Context ‘with’ statements call .close on exit of ‘with’ block
- Parameters
instance (cls is Class instance of subclass) –
oglers (name is str name of ogler instance for filename so can have multiple) – at different paths thar each use different log file directories
Boolean (temp is) – Otherwise open in persistent directory, do not clear on close
directory (True means open in temporary) – Otherwise open in persistent directory, do not clear on close
close (clear on) – Otherwise open in persistent directory, do not clear on close
Usage:
- with openOgler(name=”bob”) as ogler:
logger = ogler.getLogger() ….
with openOgler(name=”eve”, cls=SubclassedOgler)
- class hio.help.ogling.Ogler(name='main', level=logging.ERROR, temp=False, prefix=None, headDirPath=None, reopen=False, clear=False)[source]
Olgery instances retreive and configure loggers from global logging facility Only need one Ogler per application
Uses python stdlib logging module, logging.getLogger(name). Multiple calls to .getLogger() with the same name will always return a reference to the same Logger object.
- .name is str used in file name
- .level is logging severity level
- .temp is Boolean True means use /tmp directory
- .prefix is str used as part of path prefix and formating
- .headDirPath is str used as head of path
- .tailDirpath is str used as tail of path
- .altTailDirPath is str used a alternate tail of path
- .dirPath is full directory path
- .path is full file path
- .opened is Boolean, True means file is opened Otherwise False
- reopen(self, name=None, temp=None, headDirPath=None, clear=False)[source]
Use or Create if not preexistent, directory path for file .path First closes .path if already opened. If clear is True then also clears .path before reopening
- Parameters
name (name is optional) –
- if None or unchanged then ignore otherwise recreate path
When recreating path, If not provided use .name
boolean (temp is optional) –
- If None ignore Otherwise
Assign to .temp If True then open temporary directory, If False then open persistent directory
database (headDirPath is optional str head directory pathname of main) –
- if None or unchanged then ignore otherwise recreate path
When recreating path, If not provided use default .HeadDirpath
closing (clear is Boolean True means clear .path when) –
- close(self, clear=False)[source]
Set .opened to False and remove directory at .path :param clear is boolean: :param True means clear directory: