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 details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

Details for the file logworks-0.7.6.tar.gz.

File metadata

  • Download URL: logworks-0.7.6.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for logworks-0.7.6.tar.gz
Algorithm Hash digest
SHA256 e297107fe88f50dba36d2ce75ae7d1247386e6d1474cb439340097e26bdaec1f
MD5 b2ad0f871a75ffec33780635fccf83d3
BLAKE2b-256 54433a95a86056b411f7639a058340f89cbf8b04eeef953db39efe80c694de97

See more details on using hashes here.

File details

Details for the file logworks-0.7.6-py3-none-any.whl.

File metadata

File hashes

Hashes for logworks-0.7.6-py3-none-any.whl
Algorithm Hash digest
SHA256 77a69f01fa25e311f11151967af130439170c14322a30ad63d8cfef337be1dac
MD5 a6850f8e58949df35ed68661f3be7de2
BLAKE2b-256 d689c11e062ccd2860e06db8787c88b8ad630339d7807081e5f1d076bef52c83

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