Top level module cache for dailylog-lib.

class CacheRecord(d_obj=None)[source]

Bases: object

Class representing a cache record.

suppress(stifle)[source]

Suppress display of cache record.

Return type:

bool

Parameters

stifleint

Suppress if last display is > stifle seconds

Returns

bool

True if suppressed

to_dict()[source]

Convert instance to dict.

Return type:

Dict[str, int]

Returns

Dict[str, int]

Instance data as dict

class Cache(**kwargs)[source]

Bases: Config

Class to manage the cache.

log_message(key, message, **kwargs)[source]

Log a message with specified parameters, handling suppression and caching.

Return type:

bool

Parameters

keystr

Unique key for the cache record.

messagestr

The message to log.

kwargsdict
Additional keyword arguments:
  • label (str): Log level label, defaults to “ERROR”.

  • logfn (str): Path to the log file, defaults to the default log.

  • quiet (bool): If True, suppresses terminal output.

  • suppress (int): Number of seconds to suppress repeated messages, defaults to CONST_DAY.

Returns

bool

True if the message was logged to the terminal or cache was updated, False otherwise.

classmethod t_stamp()[source]

Return current time stamp.

Return type:

str

classmethod append_daily(label, message, log_fn, s_cnt=None)[source]

Append a message to the specified log file.

Return type:

None

Parameters

labelstr

Log level label DEBUG, INFO, WARNING, ERROR …

messagestr

Record to log

log_fnstr

Path name of log file

s_cntint

Number of seconds to suppress screen output.

Top level module config for dailylog-lib.

class Config(**kwargs)[source]

Bases: Options

Class to manage the configuration.

set_default_log(log_fn)[source]

Set the default log file.

Return type:

None

Parameters

log_fnstr

Absolute path to the log file

classmethod update_config(config)[source]

Update configuration from version to current version.

Parameters:

config (StrAnyDict) – previous config verstion

Return type:

Dict[str, Any]

classmethod validate_path(path)[source]

Validate the file path exists or can be created.

Parameters:

path (Path) – files spec for log

Raises:
  • FileNotFoundError – when parent directory doesn’t exist or is not a directory

  • FilePermError – when parent directory is not writable

Return type:

None

default_log()[source]

Returns the path to the default log.

Return type:

str

Returns

str

Path to the default log

classmethod validate_existing_path(path)[source]

Validate existing path.

Parameters:

path (Path) – files spec for log

Raises:
  • FileNotFoundError – when path exists but is not a file

  • FilePermError – when path exists but is not writable

Return type:

None

Top level module constants for dailylog-lib.

Top level module exceptions for dailylog.

exception FilePermError[source]

Bases: Exception

Class for file permission errors.

Foos module for dailylog-lib.

banner(text, **kwargs)[source]

Creates a banner line with the given text in the center.

Parameters: - text: str, the text to be centered. - width: int, the width of the banner line, defaults to 60. - char: str, the character to be used, defaults to “-“. - action: Optional bool, if True, use “started” as the action if False, use “exiting”, defaults to None.

Return type:

str

Returns:

str, the formatted banner line.

Logging module for wtftools package.

log_label(level)[source]

Return logger level name.

Return type:

str

Parameters

levelstr

Level number or name

Returns

str

Level name, Default if not matched, by default “ERROR”

log_level(level)[source]

Return logger level name.

Return type:

int

Parameters

levelstr

Level number or name

Returns

int

Level, default logging.WARNING

class Logger(**kwargs)[source]

Bases: Cache

Logging class for dailylog-lib package.

log(message, **kwargs)[source]

Log a message with specified parameters, handling suppression and caching.

Return type:

None

Parameters

messagestr

The message to log.

kwargsdict

Keyword arguments that can include: - caller (str): Caller name, optional. - key (str): Unique key for the cache record, optional. - label (str): Log level label, defaults to “ERROR”. - logfn (str): Path to the log file, defaults to the default log if key set. - quiet (bool): If True, suppresses terminal output. - suppress (int): Number of seconds to suppress repeated messages, defaults to CONST_DAY.

debug(message, **kwargs)[source]

Log a debug message.

Return type:

None

info(message, **kwargs)[source]

Log a info message.

Return type:

None

warning(message, **kwargs)[source]

Log a warning message.

Return type:

None

error(message, **kwargs)[source]

Log a error message.

Return type:

None

critical(message, **kwargs)[source]

Log a critical message.

Return type:

None

Top level module options for dailylog-lib.

class Options(**kwargs)[source]

Bases: object

Class to manage the options.

is_debug()[source]

Return True if debug option is greater than 0.

Return type:

bool

is_test()[source]

Return True if test option is greater than 0.

Return type:

bool

is_verbose()[source]

Return True if verbose option is greater than 0.

Return type:

bool

property debug_level: int

Return the debug level.

property verbose_level: int

Return the verbose level.

config_path()[source]

Return the config file path.

Return type:

Path

cache_path()[source]

Return the cache file path.

Return type:

Path

classmethod validate_fn_absolute(file_key, file_name)[source]

Validate an absolute file name/path.

Parameters:
  • file_key (str) – key name of file “config | cache”

  • file_name (str) – path name of file to validate

Raises:
  • ValueError – when file_name is empty string

  • ValueError – when file_name is not absolute

Returns:

validate file name/path as a string

Return type:

str