sutools module

su (Super User) tools

Per module utilities, designed to be lightweight, easy to configure, and reduce boilerplate code.

info

This package is intended to create an lower barrier for entry for logging and module level cli with sensible defaults; sutools is not intended to replace click, argparse, logging or other utility libraries. If your project requires a more flexible configuration please use the appropriate tooling.

sutools.cli(desc=None, logs=False)[source]

init cli and register to store

Parameters:
  • desc – description of the CLI

  • logs – enable logging in CLI

sutools.log()[source]

retrieve loggers namespace from store

sutools.logger(name='<frozen run', loggers=None, loglvl=20, filename='2023-03-17_02-45-05', filepath=None, filefmt=<logging.Formatter object>, fhandler=None, filecap=None, filetimeout=None, file=True, streamfmt=<logging.Formatter object>, shandler=<StreamHandler <stderr> (NOTSET)>, stream=False)[source]

init logger object and register to store

Parameters:
  • name – name of the logger

  • loggers – list of names for the logger to create

  • loglvl – logging level to use

  • filename – name of the log file

  • filepath – name of folder to create logs in

  • filefmt – format of the file logger

  • fhandler – file handler to use for logging

  • filecap – maximum number of log files to keep

  • filetimeout – define a timeout period for log files to be removed

  • file – toggle file logging

  • streamfmt – format of the stream logger

  • shandler – stream handler to use for logging

  • stream – toggle stream logging

sutools.register(func)[source]

register a function to the store

Parameters:

func – the function to register