Skip to main content

A beautiful, colorful Python logging library by karenhoyoshi

Project description

logkaren

A beautiful, colorful Python logging library by karenhoyoshi

PyPI version Python License: MIT


Installation

pip install logkaren

Quick Start

from logkaren import Logger, Loader, Home, LogLevel

# Default ColorLogger
log = Logger()
log.info("Server started on port 8080")
log.success("User logged in successfully")
log.warning("Disk usage above 80%")
log.error("Connection refused")
log.debug("Variable x = 42")

# With timing
import time
start = time.time()
time.sleep(0.5)
end = time.time()
log.success("Task done", start=start, end=end)

# Ask user input
name = log.question("What is your name? ")

# Critical — pauses and exits
log.critical("Fatal error occurred", exit_code=1)

Logger Styles

Style 1 — ColorLogger (default)

log = Logger()           # or Logger(style=1)

Colorful output with pink prefix, magenta timestamps, and colored log levels.

Style 2 — SimpleLogger

log = Logger(style=2)

Clean minimal output — great for production or CI environments.


Constructor Options

Logger(
    style=1,                          # 1 = ColorLogger, 2 = SimpleLogger
    prefix="karenhoyoshi.asia",       # Custom prefix shown in brackets
    github_repository="github.com/karenhoyoshi/myproject",  # Shown on startup
    level=LogLevel.DEBUG,             # Minimum log level to display
    log_file="logs/app.log",          # Optional file to save logs
)

Log Levels

Level Value Description
DEBUG 1 Detailed debug information
INFO 2 General information
WARNING 3 Something unexpected but non-fatal
SUCCESS 4 Operation completed successfully
FAILURE 5 Operation failed
CRITICAL 6 Fatal error — exits the program
from logkaren import Logger, LogLevel

# Only show WARNING and above
log = Logger(level=LogLevel.WARNING)

Loader

Animated terminal spinner for long-running tasks.

from logkaren import Loader
import time

# As context manager (recommended)
with Loader(desc="Fetching data from API", end="Done fetching!"):
    time.sleep(3)

# Manual control
loader = Loader(desc="Processing files")
loader.start()
time.sleep(2)
loader.stop()

Options:

Param Default Description
prefix karenhoyoshi.asia Prefix shown in the spinner
desc Loading... Description text next to the spinner
end \r Message shown when done (or \r)
timeout 0.1 Speed of animation (seconds per frame)

Home Screen

Display a styled ASCII banner at startup.

from logkaren import Home

Home(
    title="MYAPP",
    subtitle="The coolest tool ever",
    credits="by karenhoyoshi",
    adinfo1="v2.0.0",
    adinfo2="github.com/karenhoyoshi/myapp",
    clear=True,   # Clear terminal before displaying
).display()

Requires pyfiglet for the big ASCII title font (installed automatically).


Logging to File

log = Logger(log_file="logs/app.log")
log.info("This will be saved to file too")

ANSI color codes are automatically stripped from file output.


License

MIT © karenhoyoshi

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

logkaren-1.0.2.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

logkaren-1.0.2-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file logkaren-1.0.2.tar.gz.

File metadata

  • Download URL: logkaren-1.0.2.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for logkaren-1.0.2.tar.gz
Algorithm Hash digest
SHA256 0370a8e5a7344e84ceb2549952bf8dca87754c6fe6316b290336ac9cfec81ba5
MD5 4b49f2fd760c56afd02b898c7985ff2f
BLAKE2b-256 193ef7843d566a9d4ef4fef517ceed2e6ae23cf5bdf8f149dcd7687eeb28c386

See more details on using hashes here.

File details

Details for the file logkaren-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: logkaren-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for logkaren-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4cc5b8c90f4e390fb54279f5fc1a75cab3b9ca293ae5440d2395ed2905f6a26c
MD5 aeedc6d60bcf1bbbe6bdfebe03ff5a3a
BLAKE2b-256 f57566f46febfb51cfa83ff6d570c0a1db5c537756c99f69bece70b7df4d4989

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