Skip to main content

Colorize your console output.
Provides ConsoleHandler() for working with logging module to get colored logging message.

Usage Example

1. Colorize your logging output

# you can just do `from colorlog import *`
import logging, coloredlog
logging.basicConfig(
    format='%(asctime)s %(filename)s:%(lineno)d [%(levelname)s] %(message)s',
    handlers=[coloredlog.ConsoleHandler()],
    level=logging.DEBUG
)
logger = logging.getLogger(__name__)

logger.info('logging started')
logger.debug('debug message')
logger.info('informative')
logger.log(coloredlog.NOTIFY, 'notification')
logger.warning('a warning message')
logger.error('message on error occurred')
try:
    raise RuntimeError('An exception!')
except:
    logger.exception('Exception:')
logger.critical('THIS IS CRITICAL')

Result on Windows 10 result

2. Decorate your normal message

from coloredlog.color import *

print(deco('Hello, ', 0x011, bold=True) + reset() + 'world!')
print(deco('Hello, ', reverse=True) + reset() + 'world!')
print(deco('Hello, ', FG_BLUE, bold=True) + reset() + 'world!')
print(deco('Hello, ', FG_YELLOW, BG_GREEN, bold=True) + reset() + 'world!')
print(deco('Hello, ', FG_MAGENTA, bold=True) + reset() + 'w...')

# Simple convenience functions
warning("emmm, seems there is a small proble...")
error('Unknown error!')

For more information on parameter rules for deco( ), please refer to the docstring.

Result on Windows 10 result

3. For intensive use case

Since a complete run-through of deco() can be a bit time-consuming under intensive use case, you may consider method below to speed up the operation of deco()

from coloredlog.color import *

const_deco = deco('', FG_BLUE, BG_WHITE, bold=True)
# simulates intensive use case
for i in range(10):
    print(deco('Hello world for {} times'.format(i), const_deco=const_deco)) # `deco()` will return immediately

print(reset()) # reset to normal color

Result on Windows 10 result

Tested on

  • Windows 10 (python 3.6)
  • Ubuntu 16.4.1 (python 3.5)

Metadata

Release files for coloredlog 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for coloredlog 0.2.5
File Size Uploaded Provenance Actions
coloredlog-0.2.5.tar.gz 4.3 kB Without provenance Details for coloredlog-0.2.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for coloredlog 0.2.5
File Interpreter ABI Platform Actions
coloredlog-0.2.5-py3-none-any.whl Python 3 none any Details for coloredlog-0.2.5-py3-none-any.whl

Total release size: 10.0 kB

Release files / coloredlog-0.2.5.tar.gz

Download URL coloredlog-0.2.5.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f17d3b4ed8acb4df346edb4a5b3c619769cdc88d2b2f3c5023e3f9d0b869d732
BLAKE2b-256 checksum
How to use checksums
da671639a005e2b5ca433edc7538f34d9893fe855373ea89891f2b3b6f5b8c97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5

Release files / coloredlog-0.2.5-py3-none-any.whl

Download URL coloredlog-0.2.5-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9334d73103cad8cb296248961710a8ce5a09ab63905905a81635fd7980538bb9
BLAKE2b-256 checksum
How to use checksums
a881940b198fafb3d76f6e25a028a010a47a3fe644573a58745abd815341d31d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5

Security for coloredlog 0.2.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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