Skip to main content

logworks is a convenience wrapper for the logging Python module.

Project description

logworks is a convenience wrapper for the logging Python module. It is useful for me and the work I do at IHCantabria.

I make it public with best wishes, but no implication is made about its potential utility and usability for others. logworks is distributed as free software, under the GPLv3.

Some examples

NOTE: GitHub's markdown parser discards some HTML. As a result, the outputs below lack color.

Default

from logworks import logworks

logger = logworks.Logger()

logger.debug("Verbose debug")
logger.info("This is some info")
logger.ok("Everything is ok")
logger.warning("Danger! Danger!")
logger.error("Something went wrong")

Yields the following (your exact colors may vary). Note debug text is not logged.

2018-04-11 12:10:35 [INFO] This is some info
2018-04-11 12:10:35 [OK] Everything is ok
2018-04-11 12:10:35 [WARNING] Danger! Danger!
2018-04-11 12:10:35 [ERROR] Something went wrong

Debug

import logging
from logworks import logworks

logger = logworks.Logger(level=logging.DEBUG)

logger.debug("Verbose debug")

Yields (now it logs debug). Note that default color for debug is no color.

2018-04-11 12:10:35 [DEBUG] Verbose debug

No colors

from logworks import logworks

logger = logworks.Logger(use_color=False)

logger.info("This is some info")
logger.ok("Everything is ok")
logger.warning("Danger! Danger!")
logger.error("Something went wrong")

Yields:

2018-04-11 12:10:35 [INFO] This is some info
2018-04-11 12:10:35 [OK] Everything is ok
2018-04-11 12:10:35 [WARNING] Danger! Danger!
2018-04-11 12:10:35 [ERROR] Something went wrong

Custom formatter

import logging
from logworks import logworks

myformatter = logging.Formatter(
    fmt='{clevelname} - {asctime} - {message}',
    datefmt="%H:%M:%S",
    style="{"
)

logger = logworks.Logger(console_formatter=myformatter)

logger.info("This is some custom info")

Yields:

[INFO] - 12:10:35 - This is some custom info

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

logworks-0.7.6.tar.gz (18.6 kB view hashes)

Uploaded Source

Built Distribution

logworks-0.7.6-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

Supported by

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