##// END OF EJS Templates
Set default alarms to none
Set default alarms to none

File last commit:

r1084:354be9b79eeb
r1163:897c7e98cc47
Show More
log.py
45 lines | 1.2 KiB | text/x-python | PythonLexer
Juan C. Espinoza
Add tag to log's
r1051 '''
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.
Juan C. Espinoza
Add tag to log's
r1051 '''
José Chávez
added log helper
r943 import click
José Chávez
formatting
r1084
Juan C. Espinoza
Add tag to log's
r1051 def warning(message, tag='Warning'):
click.echo(click.style('[{}] {}'.format(tag, message), fg='yellow'))
pass
José Chávez
added log helper
r943
Juan C. Espinoza
Add tag to log's
r1051 def error(message, tag='Error'):
click.echo(click.style('[{}] {}'.format(tag, message), fg='red'))
pass
José Chávez
added log helper
r943
Juan C. Espinoza
Add tag to log's
r1051 def success(message, tag='Info'):
click.echo(click.style('[{}] {}'.format(tag, message), fg='green'))
pass
José Chávez
added log helper
r943
Juan C. Espinoza
Add tag to log's
r1051 def log(message, tag='Info'):
click.echo('[{}] {}'.format(tag, message))
pass
José Chávez
added log helper
r943
Juan C. Espinoza
Add tag to log's
r1051 def makelogger(tag, bg='reset', fg='reset'):
José Chávez
added log helper
r943 def func(message):
José Chávez
formatting
r1084 click.echo(click.style('[{}] {}'.format(
tag.upper(), message), bg=bg, fg=fg))
José Chávez
added log helper
r943 return func