lib-log-utils

raw JSON →
1.4.15 verified Mon Apr 27 auth: no python

A utility library for colored log messages and banners from commandline and Python. Current version 1.4.15, supports Python >=3.8.0, actively maintained.

pip install lib-log-utils
error ModuleNotFoundError: No module named 'lib_log_utils'
cause Package import name uses underscores, not hyphens.
fix
Use from lib_log_utils import LogUtil (with underscores).
error ImportError: cannot import name 'LogUtil' from 'lib_log_utils'
cause Outdated version or incorrect spelling.
fix
Ensure version >= 1.4.0 and use LogUtil (capital L, capital U).
gotcha LogUtil by default logs to stdout; ensure your application does not interfere with stderr expectations.
fix Configure LogUtil with stream parameter: LogUtil(stream=sys.stderr) for error logging.
gotcha Coloring may not work in all terminals or Windows Command Prompt without ANSI support.
fix Set environment variable LOG_UTILS_NO_COLOR=1 to disable colors, or install `colorama` for Windows support.
gotcha The banner function prints to stdout and uses special characters; may cause issues in logging pipelines.
fix Use banner(stream=some_stream) to redirect output.

Basic usage: create a LogUtil instance and use .info(), .success(), .warning(), .error() methods with colored output.

from lib_log_utils import LogUtil

log = LogUtil()
log.info('Hello, colored world!')
log.success('Task completed')
log.warning('Be careful')
log.error('Something went wrong')