Skip to main content

livelog

Release License Linux macOS Windows

livelog is yet another Python logger.

Its main purpose is to provide live logging for situation where logging to console is not possible. For example working on a GUI, TUI, a software plugin or a script instanciated from a different shell.

It provides a Logger object for your code and a built-in reader to see your logs in real time from another shell. Even if its overall behavior is opinionated it does offer some customization.

Demo

Installation

python3 -m pip install livelog

Logging

Basics

In your code, create a Logger instance with:

from livelog import Logger

logger = Logger()

Parameters

Logger takes multiple optional arguments:

  • file (str): Path for your logging file. Default is a file named "livelog.log" in your system tmp directory.
  • level (str): Minimum level to be logged. Default is "DEBUG", you can also select "INFO", "WARNING", and "ERROR". Note that level filtering can also be done directly from the reader.
  • enabled (bool): Whether logging is enabled or not. Default is True.
  • erase (bool): Whether preexisting logging file should be erased or not. Default is True.
from livelog import Logger

logger = Logger(file= "/home/user/",
                level = "INFO",
                enabled = False,
                erase = False)

Methods

Use the following methods to write log messages:

  • logger.debug("message")
  • logger.info("message")
  • logger.warn("message")
  • logger.error("message")
from livelog import Logger

logger = Logger()
logger.debug("This is a debug message")
logger.info("This is an info message")
logger.warn("This is a warning message")
logger.error("This is an error message")

Attributes

You can get and set attributes after instantiation:

from livelog import Logger

logger = Logger(file="/tmp/file.log")
logger.debug("This will write to /tmp/file.log")

logger.file = "/tmp/another_file.log"
logger.debug("This will write to /tmp/another_file.log")

logger.level = "ERROR"
logger.debug("This debug message will not be written.")

logger.enabled = False
logger.error("Logging disabled. This error message will not be written.")

Singleton

livelog also provides a built-in singleton:

your_first_file.py

from livelog import LoggerSingleton


logger = LoggerSingleton(file="/tmp/file.log")
logger.debug("This will write to /tmp/file.log")

another_file.py

from livelog import LoggerSingleton


logger = LoggerSingleton()
# LoggerSingleton() returned the instance from your first file.
logger.debug("This will write to /tmp/file.log")

Reading

Although you can access to your logging file like any other, you can use the provided reader.

If you did not specify a file for Logger simply use:

python3 -m livelog

livelog will read in real time the default log file.

Options

  • -f or --file - Set the path of your logging file
  • -l or --level - Set the minimum log level to be read.
  • --nocolors - Do not print colors

Example:

python3 -m livelog -f /tmp/myfile.log -l INFO --nocolors

Release files for livelog 1.0.1

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

Source distribution (sdist)

Source distribution for livelog 1.0.1
File Size Uploaded
livelog-1.0.1.tar.gz 19.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for livelog 1.0.1
File Interpreter ABI Platform
livelog-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 38.4 kB

Release files / livelog-1.0.1.tar.gz

Download URL livelog-1.0.1.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
fac082e129317f3a0ad3f943baff342ae111c526874018853b9d84b26d8e3d8d
BLAKE2b-256 checksum
How to use checksums
a9d64cb1dcd07160677d6fd71407a6a814df9ac1675bbfe08aea7b7d23db6ecc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / livelog-1.0.1-py3-none-any.whl

Download URL livelog-1.0.1-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a5ff3b6d1ff173d86bef7101ea2e61aa0517a2ac38f5e9844515eb6caffeb97
BLAKE2b-256 checksum
How to use checksums
0ec5132486dd5c9a340d1d3e7a28deb5b622a5eeb2e9584aa2ae0a96dee1f29b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.0.9

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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