Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.2 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > System > Logging

    colorlog 1.4

    Download button

    No screenshots available
    Downloads: 86  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Sam Clements | More programs
    MIT/X Consortium Lic... / FREE
    September 8th, 2012, 08:52 GMT
    ROOT / System / Logging

     Read user reviews (0)  Refer to a friend  Subscribe

    colorlog description

    Log formatting with colors!

    colorlog is a formatter for use with Python's logging module.

    It allows colors to be placed in the format string, which is mostly useful when paired with a StreamHandler that is outputting to a terminal. This is accomplished by added a set of terminal color codes to the record before it is used to format the string.

    Usage

    ColoredFormatter requires at minumum a format string, and takes two options - reset (implictly add a reset code at the end of message strings, defaults to true) and color_levels (a mapping of record level names to color names, defaults to colorlog.DEFAULT_COLOR_LEVELS).

    from colorlog import ColoredFormatter

    formatstring = "%(bg_level)s%(levelname)-8s%(reset)s %(blue)%(message)s"

    levels = {
     'DEBUG': 'cyan',
     'INFO': 'green',
     'WARNING': 'yellow',
     'ERROR': 'red',
     'CRITICAL': 'red',
    }


    formatter = ColoredFormatter(formatstring, reset=True, color_levels=levels)

    The formatter can then be used in a normal logging setup.

    Codes

    The following values are made availible for use in the format string:

    - fg_{colorname}, bg_{colorname}: Foreground and background colors. The colors names are black, red, green, yellow, blue, purple, cyan and white.
    - bold: Bold output.
    - reset: Clear all formatting (both foreground and background colors).
    - fg_level, bg_level: Return the color associated with the records level (from color_levels).


    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    log formatting | Python logging | Python | log | formatting

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM