Skip to main content

A Simple and Colorful Python Logging Library

Project description

LOGKISS

Tests Python License codecov

LOGKISS (Keep It Simple and Stupid Logger) is a user-friendly logging library for Python. Built on top of the standard logging module, it provides an interface with sensible defaults out of the box.

Features

  • Colorful by Default: LOGKISS uses KissConsoleHandler by default, which outputs logs in different colors based on log levels.
  • Drop-in Replacement: Use it as a drop-in replacement for the standard logging module with import logkiss as logging.
  • Flexible Switching: Easily switch back to the standard ConsoleHandler when needed.

Installation

pip install logkiss

Usage

LOGKISS provides three different ways to enhance your logging experience:

1. Colorful Console Logging

Use LOGKISS directly to get beautiful colored log output with minimal setup:

import logkiss

logger = logkiss.getLogger("example1")
logger.warning("Colorful output in your terminal")

picture 0

2. Using as a logging module replacement:

import logkiss as logging

logger2 = logging.getLogger("example2")
logger2.warning("Also colorful warning")
logger2.error("Also colorful error")

picture 1

3. Using custom handler configuration:

import logging
import logkiss

Get a logger with standard logging module

logger3 = logging.getLogger("example3")

Clear existing handlers

logger3.handlers.clear()

Add logkiss custom handler

handler = logkiss.KissConsoleHandler()  # カラフルな出力用のハンドラー
handler.setFormatter(logkiss.ColoredFormatter(use_color=True))
logger3.addHandler(handler)

Log with customized handler

logger3.error("Customized colorful output")

Sample Output

When you run the above code, you will see output similar to the following:

# Output from logger1.info():
2025-04-08 12:27:43,215 INFO  | example.py:5   | Colorful output

# Output from logger2.warning():
2025-04-08 12:27:43,219 WARN  | example.py:11  | Also colorful output

# Output from logger3.error():
2025-04-08 12:27:43,224,123 ERROR | example.py:21 | Standard monochrome output

The first two log messages will be displayed with color formatting in your terminal, while the third message will use the standard logging format without colors.

logkiss-terminal-demo

Environment Variables

LOGKISS can be configured using the following environment variables:

  • LOGKISS_DEBUG: Enable debug mode by setting to 1, true, or yes. When enabled:
    • Root logger's level is set to DEBUG instead of INFO
    • More detailed logging information is displayed
  • LOGKISS_DISABLE_COLOR: Disable colored output by setting to 1, true, or yes
  • NO_COLOR: variable to disable colors (any value)

Example:

# Enable debug mode
export LOGKISS_DEBUG=1

# Run your Python script
python your_script.py

Behavior with Modules and Libraries

Logkiss modifies the behavior of the Python logging system. This has some implications you should be aware of:

Module Interactions

  • When you import logkiss in a module, it affects the global logging configuration for the entire Python process
  • If you import logkiss in module A, and then import standard logging in module B, the logging in module B will also use logkiss's colorful output
  • To switch a specific logger back to standard behavior, use logkiss.use_console_handler(logger)

Third-Party Library Compatibility

  • Most Python libraries that use the standard logging module will automatically benefit from logkiss's colorful output
  • However, libraries that define custom handlers or formatters (like matplotlib) may not display colored output
  • Libraries that redirect their logs or use advanced logging configurations might have varying results

Best Practices

  • In simple applications, importing logkiss at the entry point will colorize logs throughout the application
  • For more complex applications, you may want to be more selective about which loggers use colorful output

Configuration

For detailed configuration options, please refer to CONFIG.md.

Acknowledgments

The output format of logkiss is inspired by deigan / loguru

License

This project is licensed under the MIT License - see the LICENSE file for details.

Other Languages

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logkiss-2.3.0a1.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logkiss-2.3.0a1-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file logkiss-2.3.0a1.tar.gz.

File metadata

  • Download URL: logkiss-2.3.0a1.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for logkiss-2.3.0a1.tar.gz
Algorithm Hash digest
SHA256 74f5c615930c65f6923402a741a52fa7ef1e8cc854131274db52808deab16a11
MD5 755dd1732e13286f4e3a10704053b7d3
BLAKE2b-256 5cb6dc8cfd36314385941d7c489c5d02904bf0321be6812a55ecf29bbe86ee1c

See more details on using hashes here.

File details

Details for the file logkiss-2.3.0a1-py3-none-any.whl.

File metadata

  • Download URL: logkiss-2.3.0a1-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for logkiss-2.3.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 6393b5ea4535c04642b004872d7d6b9b3d61e5e90a66cb537e3272752386cc9c
MD5 72fa66140c53b09dca8b6854c247f4b5
BLAKE2b-256 254c6e7c86d86a6d6acfcba4aadbc00718f7f5985785815818158c95d51c5146

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page