Logger

class utils.Logger

Bases: object

Custom logger with InfluxDB backend

Methods Summary

comms(msg, **kwargs) Get list of categories and human readable names.
debug(msg, **kwargs) See comms()
device(msg, **kwargs) See comms()
error(msg, **kwargs) See comms()
funcexec(msg, **kwargs) See comms()
get_categories() Get list of categories and human readable names.
interaction(msg, **kwargs) See comms()
list_records(**kwargs) List log records.
purge(**kwargs) Purge (delete) log records.
stats() Get statistics about the current logs

Methods Documentation

comms(msg: str, **kwargs)

Get list of categories and human readable names.

Parameters:msg – Message to record
Keyword Arguments:
 * – All keyworord arguments which are JSON serialisable are recorded as sublimental information.
debug(msg: str, **kwargs)

See comms()

device(msg: str, **kwargs)

See comms()

error(msg: str, **kwargs)

See comms()

funcexec(msg: str, **kwargs)

See comms()

get_categories()

Get list of categories and human readable names.

Returns:List of tuples (category_id, fiendly name)
Return type:list
interaction(msg: str, **kwargs)

See comms()

list_records(**kwargs)

List log records.

Keyword Arguments:
 
  • cat (str) – Category
  • limit (int) – Limit results
  • offset (int) – Results offset
  • start (str) – UTC Datetime formatted as string - Results period start
  • end (str) – UTC Datetime formatted as string - Results period end
  • orderby (str) – Formatted as field and order e.g. time ASC or time DESC
Returns:

Dictionary of results and pagination:

{
    total: Total number of records,
    page_start: Page starts at result x,
    page_end: Page ends at result x,
    num_pages: Total number of pages,
    page_num: Current page number,
    results: List of results
}

Return type:

dict

purge(**kwargs)

Purge (delete) log records.

Keyword Arguments:
 
  • start (str) – UTC Datetime formatted as string - Period start
  • end (str) – UTC Datetime formatted as string - Period end
  • categories (list) – List pf category ids to delete
stats()

Get statistics about the current logs

Returns:Dictionary containing overall record ‘count’ and counts for each of the ‘categories’
Return type:dict