Skip to main content

lica-log

Introduction

lica-log is a lightweight logging utility for day-to-day LICA Python command-line applications. It defines a minimal logging interface and provides adapters that configure the standard Python root logger from parsed command-line arguments.

The package supports console logging, optional file logging with rotation, and an optional Textual-compatible handler. Application code depends only on the Logger protocol, while the concrete logging behaviour is supplied by an adapter.

Installation

Install lica-log directly from the lica-ng Git repository:

pip install lica-log

To include support for Textual applications, install the textual optional dependency group:

pip install "lica-log[textual]"

or add to your pyproject.toml dependencies list

or add it to your pyproject.toml:

[project]
dependencies = [
    "lica-log",
]

For a Textual-based application:

[project]
dependencies = [
    "lica-log[textual]",
]

Interfaces

lica-log defines its logging contracts using typing.Protocol. Adapters do not need to inherit from these protocols explicitly; they only need to provide the required methods.

Synchronous logger

from typing import Protocol


class Logger(Protocol):
    def configure(self) -> None: ...

Asynchronous logger

from logging.handlers import QueueListener
from typing import Protocol


class AsyncLogger(Protocol):
    def configure(self) -> QueueListener: ...

Adapters

Adapter Module Extra Description
DefaultLogger lica_log.adapters.default — Configures the root logger using console and/or file handlers.
TextualLogger lica_log.adapters.textual textual Configures the root logger for Textual applications, adding a textual.logging.TextualHandler when requested.

Both adapters accept a parsed argparse.Namespace, an optional log format, and a rotation flag:

DefaultLogger(args: Namespace, fmt: str | None = None, rotate: bool = False) -> None

The default log format string is "%(asctime)s [%(levelname)-8s] %(message)s". Another useful format string to be passed when debugging when creating the adapter can be "%(asctime)s [%(levelname)-8s] [%(name)s] %(message)s".

The expected namespace attributes are:

  • log_level: logging level, of type lica_log.LogLevel.
  • console: enables a StreamHandler when true.
  • log_file: path to a log file; enables file logging when set.
  • textual: enables the Textual log handler in the Textual adapter.

These are usually provided by default by its sister package lica-cli

With rotate=True, file logging uses TimedRotatingFileHandler; otherwise it uses WatchedFileHandler, which is suitable for external log-rotation tools.

Usage example, with lica-cli package

import logging
import sys
from argparse import ArgumentParser, Namespace

from lica_cli import parse_args, run_cli
from lica_log.adapters.default import DefaultLogger

from myprog import __version__

DESCRIPTION = "My program short description"

log = logging.getLogger(__name__.split(".")[-1])


def add_args(parser: ArgumentParser) -> None:
    """Add extra CLI arguments here"""
    pass


def cli_main(args: Namespace) -> None:
    log.info("Hello World")


def main():
    args = parse_args(add_args, __name__, __version__, DESCRIPTION)
    logger = DefaultLogger(args)
    logger.configure()

    return_code = run_cli(cli_main, args, __name__, __version__, logger)
    sys.exit(return_code)


if __name__ == "__main__":
    main()

Metadata

Release files for lica-log 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lica-log 0.1.0
File Size Uploaded Provenance Actions
lica_log-0.1.0.tar.gz 5.5 kB Without provenance Details for lica_log-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lica-log 0.1.0
File Interpreter ABI Platform Actions
lica_log-0.1.0-py3-none-any.whl Python 3 none any Details for lica_log-0.1.0-py3-none-any.whl

Total release size: 15.9 kB

Release files / lica_log-0.1.0.tar.gz

Download URL lica_log-0.1.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a4172a3cf9590c801a6629ff91c514eed9ac8a4ddc7acb75816afcf797c39f98
BLAKE2b-256 checksum
How to use checksums
692cf656ad4911ac4da90263f187d96a6ab9cc4dce5f71c39d392e9d98e9602c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / lica_log-0.1.0-py3-none-any.whl

Download URL lica_log-0.1.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5227f62cafdf95f7dd8057a318a9b9579c1dd9e9605e9e2d7583a74b5f132e77
BLAKE2b-256 checksum
How to use checksums
761a9fa5430bdcf6b9dcbf311c7ad131c39e3f07409592b8cc39cdf1242e755f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for lica-log 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page