Skip to content

Commit 1af1f44

Browse files
committed
ver 0.15.7.6
miscs
1 parent 5c558c1 commit 1af1f44

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

npy/log/setters.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
_sh = None
99
LOGGING_TO_FILE = False
1010
LOGGING_TO_TELEGRAM = False
11+
DATE_FMT = "%d %b %H:%M:%S"
12+
LOG_FMT = '[%(asctime)s] %(message)s'
1113

12-
13-
__all__ = ['verbosity', 'save', 'telegram']
14+
__all__ = ['verbosity', 'save', 'telegram', 'set_datefmt', 'set_fmt']
1415

1516

1617
def _init():
@@ -22,24 +23,34 @@ def _init():
2223

2324
_logger.setLevel(logging.DEBUG)
2425
level_styles = {
25-
'critical': {'color': 'red', 'bold': True},
26-
'error': {'color': 'yellow'},
27-
'warning': {'color': 'green', 'bold': True},
28-
'info': {},
29-
'debug': {'color': 'black', 'bright': True},
30-
}
26+
'critical': {'color': 'red', 'bold': True},
27+
'error': {'color': 'yellow'},
28+
'warning': {'color': 'green', 'bold': True},
29+
'info': {},
30+
'debug': {'color': 'black', 'bright': True},
31+
}
3132
field_styles = {
3233
'asctime': {'color': 'blue'},
3334
'levelname': {'color': 'yellow', 'faint': True}
3435
}
3536
coloredlogs.install(level='DEBUG', logger=_logger,
36-
fmt='[%(asctime)s] %(message)s',
37-
datefmt="%d %b %H:%M:%S",
37+
fmt=LOG_FMT,
38+
datefmt=DATE_FMT,
3839
field_styles=field_styles,
3940
level_styles=level_styles)
4041
_sh = _logger.handlers[0]
4142

4243

44+
def set_datefmt(v):
45+
global DATE_FMT
46+
DATE_FMT = v
47+
48+
49+
def set_fmt(v):
50+
global LOG_FMT
51+
LOG_FMT = v
52+
53+
4354
def save(fpath='log/log.log'):
4455
global LOGGING_TO_FILE
4556

@@ -92,7 +103,6 @@ def telegram(level=3):
92103
from .telegram_handler import TelegramHandler
93104
global LOGGING_TO_TELEGRAM
94105
if not LOGGING_TO_TELEGRAM:
95-
96106
fmt = logging.Formatter('%(message)s')
97107
th = TelegramHandler()
98108
th.setFormatter(fmt)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(name='nuclear-python',
1212

13-
version='0.15.7.5',
13+
version='0.15.7.6',
1414

1515
url='https://github.com/nuclearboy95/nuclear-python',
1616

0 commit comments

Comments
 (0)