##// END OF EJS Templates
merge with BLTR and Madrigal modules
merge with BLTR and Madrigal modules

File last commit:

r944:0efe9dc73bde
r1032:c711a14430f7 merge
Show More
log.py
45 lines | 1.1 KiB | text/x-python | PythonLexer
José Chávez
added log helper
r943 """.
SCHAINPY - LOG
Simple helper for log standarization
Usage:
from schainpy.utils import log
log.error('A kitten died beacuse of you')
log.warning('You are doing it wrong but what the heck, I'll allow it)
log.succes('YOU ROCK!')
To create your own logger inside your class do it like this:
from schainpy.utils import log
awesomeLogger = log.makelogger("never gonna", bg="red", fg="white")
awesomeLogger('give you up')
which will look like this:
[NEVER GONNA] - give you up
with color red as background and white as foreground.
"""
import click
def warning(message):
click.echo(click.style('[WARNING] - ' + message, fg='yellow'))
pass
def error(message):
José Chávez
1.0
r944 click.echo(click.style('[ERROR] - ' + message, fg='red'))
José Chávez
added log helper
r943 pass
def success(message):
José Chávez
1.0
r944 click.echo(click.style(message, fg='green'))
José Chávez
added log helper
r943 pass
def log(message):
click.echo('[LOG] - ' + message)
pass
def makelogger(topic, bg='reset', fg='reset'):
def func(message):
click.echo(click.style('[{}] - '.format(topic.upper()) + message,
bg=bg, fg=fg))
return func