Skip to main content

charlogger

A logging library for Python.

I've been using this myself for a while, and I thought that I may as well release it.

It's filled with bad code, but now that it is public, I'll probably improve it over time.

logger example

Installation

You can install charlogger with pip install charlogger.

How to use

Simple example

import charlogger

logger = charlogger.Logger()
logger.info("What a great logging library!")

Advanced example

import charlogger

# All parameters are optional.
logger = charlogger.Logger(
    debug=True, # Whether to enable the output of debug logs
    default_prefix="your prefix",
    color_text=False, # Whether to have the info text be colored
    log_file_patj=open("log.txt", "a"), # The file to put logs in
    indent_level=8, # The indentation of the text when output.
    centered=True # Whether to center text in the console.
)

logger.info("What a great logging library!")

My personal configuration (best)

import charlogger

logger = charlogger.Logger(
    debug=True,
    default_prefix="<TIME> | WORKER-001",
    color_text=True
)
logger.info("What a great logging library!")

More in-depth documentation

defaultPrefix

When initializing a Logger, you have the option of default_prefix.

For now, if you add "<TIME>" anywhere in that string, it will replace it with the time of the logging.

For instance, the following code will print 18:26:15 | hi! | i > What a great logging library!

import charlogger

logger = charlogger.Logger(
    debug=True,
    defaultPrefix="<TIME> hi!"
)
logger.info("What a great logging library!")

Logging methods

Possible arguments

import charlogger

logger = charlogger.Logger()
logger.info("What a great logging library!") # i > What a great logging library! 
logger.info(title="DOCUMENTATION", data="What a great logging library!") # i > [DOCUMENTATION] What a great logging library! 

All possible methods

import charlogger

logger = charlogger.Logger()
logger.info("What a great logging library!")
logger.warn("What a great logging library!")
logger.error("What a great logging library!")
logger.debug("What a great logging library!")
logger.valid("What a great logging library!")
logger.invalid("What a great logging library!")
logger.plus("What a great logging library!")
logger.paid("What a great logging library!")

Special methods

import charlogger

logger = charlogger.Logger()

# I can't imagine this one being all that useful. It's more there for my personal projects that use it,
logger.choice(1, "Option 1") # 1 > Option 1 

# Will wait for user input in the console.
name = logger.ask("What is your name?") # ? > What is your name? > 
print(name)

Release files for charlogger 1.2.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 charlogger 1.2.1
File Size Uploaded
charlogger-1.2.1.tar.gz 3.4 kB Details

Release files / charlogger-1.2.1.tar.gz

Download URL charlogger-1.2.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c3c461c7868d5c2a46353c0978d1a5ff92a53d7a6bce1b03a6cf8e6ceb97ee62
BLAKE2b-256 checksum
How to use checksums
6d5dff7564da36ccbb61a729e68dbaf65ae6757bbc8ebed2c129aa2f9b4f7843
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Release history Release notifications | RSS feed

This release

1.2.1 This release

1 release file

1.2

1 release file

1.1

1 release file

1.0

1 release file

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