Add save log

This commit is contained in:
Mauricio Baeza 2020-11-01 15:01:38 -06:00
parent 18ad5a2b0c
commit 8b04605bf1
2 changed files with 9 additions and 9 deletions

View File

@ -1,15 +1,6 @@
ID_EXTENSION = ''
# ~ FILTER_PDF = '/org.openoffice.Office.Common/Filter/PDF/Export/' # ~ FILTER_PDF = '/org.openoffice.Office.Common/Filter/PDF/Export/'
def save_log(path, data):
with open(path, 'a') as out:
out.write('{} -{}- '.format(str(now())[:19], LOG_NAME))
pprint(data, stream=out)
return
def run_in_thread(fn): def run_in_thread(fn):
def run(*k, **kw): def run(*k, **kw):
t = threading.Thread(target=fn, args=k, kwargs=kw) t = threading.Thread(target=fn, args=k, kwargs=kw)

View File

@ -43,6 +43,7 @@ from decimal import Decimal
from enum import IntEnum from enum import IntEnum
from functools import wraps from functools import wraps
from pathlib import Path from pathlib import Path
from pprint import pprint
from typing import Any from typing import Any
import uno import uno
@ -86,6 +87,7 @@ logging.addLevelName(logging.INFO, '\x1b[32mINFO\033[1;0m')
logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT, datefmt=LOG_DATE) logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT, datefmt=LOG_DATE)
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
LOG_NAME = 'ZAZ'
LEFT = 0 LEFT = 0
CENTER = 1 CENTER = 1
@ -250,6 +252,13 @@ def info(*args):
return return
def save_log(path, data):
with open(path, 'a') as f:
f.write(f'{str(now())[:19]} -{LOG_NAME}- ')
pprint(data, stream=f)
return
def catch_exception(f): def catch_exception(f):
@wraps(f) @wraps(f)
def func(*args, **kwargs): def func(*args, **kwargs):