Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

elegant console logger for python

Project description

🖥 Consoly

Elegant Console Logger for Python

MIT

Installation

From PyPI

pip install consoly

From Github

pip install git+https://github.com/OAlienO/consoly.git

Getting Started

from consoly import consoly

consoly.critical('Bomb!!')
consoly.error('Oh shit...')
consoly.warning('Chill')
consoly.info('Just some information')
consoly.debug('Fuck bugs')
from consoly import consoly

consoly.level = consoly.DEBUG
consoly.defaults = { 'badge': True, 'time': True }

consoly.critical('Bomb!!')
consoly.error('Oh shit...')
consoly.warning('Chill')
consoly.info('Just some information')
consoly.debug('Fuck bugs')

Document

type of levels

type level alias
critical 50 consoly.CRITICAL
error 40 consoly.ERROR
warning 30 consoly.WARNING
info 20 consoly.INFO
debug 10 consoly.DEBUG

custom type of level

consoly.types['success'] = {
    'level': 25,
    'color': Color.green,
    'icon': '✔'
}
consoly.level = consoly.SUCCESS
consoly.success('it works')

Consoly

default instance consoly is created by Consoly(FancyFormatter())

consoly.level

default to 0 ( print every messages )

consoly.level = consoly.ERROR

consoly.defaults

default to {}

this is the default options pass to formatter

consoly.defaults = { 'badge': True }

consoly.types

see type of levels

consoly.formatter

see Formatter

Formatter

default formatter is FancyFormatter

FancyFormatter

option for FancyFormatter

# set option default
consoly.defaults = { 'badge': True, 'time': True, 'short': True }
consoly.debug('hello')

# set option directly
consoly.debug('hello', badge = True, time = True, short = True)

set output file ( default is sys.stdout )

consoly.formatter.file = open('service.log', 'w')

custom formatter

from consoly import Formatter

class MyFormatter(Formatter):
    def format(self, text, typeData, formatData):
        name  = typeData['name']
        color = typeData['color']
        bold  = formatData.get('bold', False)
        if bold: color = color.bold
        self.write(f'{color.paint(name)} - {text}')

consoly.formatter = MyFormatter()

For example consoly.error('test', testOption = 10)

text will be test
typeData will be
{
    'name': 'error',
    'level': 40,
    'color': Color.red,
    'icon': '✖'
}
formatData will be
{
    'testOption': 10
}

Project details


Release history Release notifications

This version

0.0.1

Download files

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

Files for consoly, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size consoly-0.0.1-py3-none-any.whl (5.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size consoly-0.0.1.tar.gz (4.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page