79 lines
1.9 KiB
Python
79 lines
1.9 KiB
Python
|
|
#!/usr/bin/env python
|
||
|
|
|
||
|
|
import enum
|
||
|
|
import itertools
|
||
|
|
import json
|
||
|
|
import os
|
||
|
|
import re
|
||
|
|
import sys
|
||
|
|
from dataclasses import KW_ONLY, dataclass, field
|
||
|
|
from functools import partial, partialmethod
|
||
|
|
from operator import itemgetter
|
||
|
|
from time import sleep
|
||
|
|
|
||
|
|
import defl
|
||
|
|
from defl import CLIError, DotDict, Null, Path, Undefined, cl, log
|
||
|
|
from defl._run_ import *
|
||
|
|
from defl._assert_ import Assert
|
||
|
|
from defl._typing_ import *
|
||
|
|
from defl.testing_ import Tester
|
||
|
|
|
||
|
|
tester = Tester(name=__file__)
|
||
|
|
|
||
|
|
# assert (u := log.toDict()) == {
|
||
|
|
# 'e': {
|
||
|
|
# 'name': 'error',
|
||
|
|
# 'color': '\x1b[1m\x1b[38;2;255;65;65m',
|
||
|
|
# 'lineInfo': False,
|
||
|
|
# 'enabled': True,
|
||
|
|
# 'tgt': '<stderr>'
|
||
|
|
# },
|
||
|
|
# 'w': {
|
||
|
|
# 'name': 'warning',
|
||
|
|
# 'color': '\x1b[1m\x1b[38;2;255;255;65m',
|
||
|
|
# 'lineInfo': False,
|
||
|
|
# 'enabled': True,
|
||
|
|
# 'tgt': '<stderr>'
|
||
|
|
# },
|
||
|
|
# 'i': {
|
||
|
|
# 'name': 'info',
|
||
|
|
# 'color': '\x1b[1m\x1b[38;2;255;65;255m',
|
||
|
|
# 'lineInfo': False,
|
||
|
|
# 'enabled': True,
|
||
|
|
# 'tgt': '<stderr>'
|
||
|
|
# },
|
||
|
|
# 'd': {
|
||
|
|
# 'name': 'debug',
|
||
|
|
# 'color': '\x1b[1m\x1b[38;2;0;255;255m',
|
||
|
|
# 'lineInfo': True,
|
||
|
|
# 'enabled': True,
|
||
|
|
# 'tgt': '<stderr>'
|
||
|
|
# }
|
||
|
|
# }, u
|
||
|
|
|
||
|
|
@tester.add()
|
||
|
|
def run():
|
||
|
|
tm = {
|
||
|
|
'info': io.StringIO(),
|
||
|
|
'debug': io.StringIO(),
|
||
|
|
'error': io.StringIO(),
|
||
|
|
'warning': io.StringIO(),
|
||
|
|
}
|
||
|
|
l = defl.Logger()
|
||
|
|
l.setLevel(None, colorMap='', lineInfoMap=False, tgtMap=tm)
|
||
|
|
l.info('info')
|
||
|
|
l.debug('debug')
|
||
|
|
l.error('error')
|
||
|
|
l.warning('warning')
|
||
|
|
|
||
|
|
Assert(tm['info'].getvalue()) == 'info\n'
|
||
|
|
Assert(tm['debug'].getvalue()) == 'debug\n'
|
||
|
|
Assert(tm['error'].getvalue()) == 'error\n'
|
||
|
|
Assert(tm['warning'].getvalue()) == 'warning\n'
|
||
|
|
|
||
|
|
log.info(tester.run())
|
||
|
|
tester.exitWithStatus()
|
||
|
|
|
||
|
|
# for i in ch:
|
||
|
|
# print(defl.printTable([[y for y in x] for x in ch], squareFill=T))
|