hio.help.ogling

hio.help.ogling module

Provides python stdlib logging module support

Module Contents

hio.help.ogling.initOgler(level=logging.CRITICAL, **kwa)

Initialize the ogler global instance once.

Usage: assign ogler = hio.help.ogling.initOgler() at module top level. Critical is most severe to restrict logging by default. force is Boolean True to reinit even if global ogler is not None; level is default logging level. Call in package .__init__ to ensure that global ogler is defined by default. Users may reset level and reopen log file before calling ogler.getLoggers().

hio.help.ogling.openOgler(cls=None, name='test', temp=True, **kwa)

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, consoled=True, syslogged=True, filed=True, when='H', interval=1, count=48)

Olger instances provide loggers as 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

usage specific component used in file name

Type:

str

level

logging severity level

Type:

int

temp

True means use /tmp directory

Type:

bool

prefix

application specific path prefix and formating

Type:

str

headDirPath

head of path

Type:

str

dirPath

full directory path

Type:

str

path

full file path

Type:

str

opened

True means file is opened, False not opened

Type:

bool

consoled

True means log to console (stderr), False do not

Type:

bool

syslogged

True means log to syslog, False do not

Type:

bool

filed

True means log to rotating file at .path, False do not

Type:

bool

when

interval type for timed rotating file handler

Type:

str

interval

length of interval of type when

Type:

int

count

backup count number of backups to keep

Type:

int

reopen(name=None, temp=None, headDirPath=None, clear=False)

Create file handler log. Use or Create if not preexistent, directory path .dirPath 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(clear=False)

Set .opened to False and remove directory at .path :param clear is boolean: :param True means clear directory:

clearDirPath()

Remove logfile directory at .dirPath

resetLevel(name=__name__, level=None, globally=False)

Resets the level of preexisting loggers to level. If level is None then use .level

getLogger(name=__name__, level=None)

Returns Basic Logger default is to name logger after module