elegant console logger for python
Project description
🖥 Consoly
Elegant Console Logger for Python
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 | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file consoly-0.0.1.tar.gz.
File metadata
- Download URL: consoly-0.0.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67c6389b5c9979d43189a6fbdf5cdc232b4e03d3893015dcb0bf858ebe7759a3
|
|
| MD5 |
163e4cdf357ec281eb778e81bf8a7829
|
|
| BLAKE2b-256 |
0622b334d34af8ede360f0b14a9413208edc13a3720dd19ee5b51ef607da74fc
|
File details
Details for the file consoly-0.0.1-py3-none-any.whl.
File metadata
- Download URL: consoly-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72969625720ac6ad519ed65973ae0b3db0a8e30bac3d004e4c6e24decf755951
|
|
| MD5 |
2f33b3c7eccd80537f9820035cf31660
|
|
| BLAKE2b-256 |
f8406234ca124e259bd6dd66c72fd8720da81d0dc57997eaf45d35c02e479eeb
|