Skip to main content

Colored console logs

Project description

Colored console logs for Python 3(>=3.6)

The project is aimed to give specific handlers and log formatters to users for coloring stream logs in multiple ways.
Among the main features some utilities are also provided in order to make use easier.

Outputs

Output of the logger is defaulted to stdout but can be changed just in case as normal logger.

Formats

All default formatting styles are supported (%(levelname)s, {levelname} and ${levelname}).

Modes

There are four different modes at the moment for coloring:

  • Mode 0 - NO_COLOR
    No coloring (output formatting) is done, everything remains the same as in normal cases
  • Mode 1 - LEVEL
    Only levelname is colored according to the setup
  • Mode 2 - MESSAGE
    Only message is colored according to the setup
  • Mode 3 - ALL
    The whole output is colored according to the setup

Colors

Colors are stored in an enum and represent standard terminal formatting escapes such as \x1b[0m.
The following colors could be used (and represent the following formatting):

NO_COLOR = "\x1b[0m"  
BLACK = "\x1b[30m"  
RED = "\x1b[31m"  
GREEN = "\x1b[32m"  
YELLOW = "\x1b[33m"  
BLUE = "\x1b[34m"  
MAGENTA = "\x1b[35m"  
CYAN = "\x1b[36m"  
LIGHT_GRAY = "\x1b[37m"  
DARK_GRAY = "\x1b[90m"  
LIGHT_RED = "\x1b[91m"  
LIGHT_GREEN = "\x1b[92m"  
LIGHT_YELLOW = "\x1b[93m"  
LIGHT_BLUE = "\x1b[94m"  
LIGHT_MAGENTA = "\x1b[95m"  
LIGHT_CYAN = "\x1b[96m"  
WHITE = "\x1b[97m"  

Levels

The level can be set through the Handler and Formatter objects as well.
The defaults are the following:

logging.NOTSET: TerminalColors.NO_COLOR,
logging.DEBUG: TerminalColors.BLUE,
logging.INFO: TerminalColors.GREEN,
logging.WARNING: TerminalColors.YELLOW,
logging.ERROR: TerminalColors.RED,
logging.CRITICAL: TerminalColors.MAGENTA

Install

pip3 install cclogs

Basic usage

See examples attached

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

cclogs-1.0.4-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file cclogs-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: cclogs-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for cclogs-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 50efe871477148aafd926e9a78f95c92011bba9165e4889baef09a3230c3e267
MD5 4c191f11909a4608b72a7b03ee16604b
BLAKE2b-256 b995a81e61d67cc22b0f24f2d460775ac43a69f91f44bfacb2cdcb2a326688d9

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