- Add coding statement
- Import all modules in one line where possible
- Order: __future__, typing, plain imports, from imports,
janware modules
Signed-off-by: Jan Lindemann <jan@janware.com>
<W> jw-client-devops-web.py [ 29] Exiting jw-client-devops-web.py
Exception ignored in: <function App.__del__ at 0x7f3ddeb8f560>
Traceback (most recent call last):
File "/home/jan/local/src/jw.dev/proj/jw-client-devops-web/src/python/jw/devops/client/web/cmds/App.py", line 43, in __del__
File "/home/jan/local/src/jw.dev/proj/jw-python/tools/python/jwutils/log.py", line 167, in slog
File "/home/jan/local/src/jw.dev/proj/jw-python/tools/python/jwutils/log.py", line 126, in get_caller_pos
AttributeError: 'NoneType' object has no attribute '__name__'
Signed-off-by: Jan Lindemann <jan@janware.com>
Add functions log.(add|rm)_capture_stream(). The functions are meant
to capture everything passed to syslog into the stream objects
installed by it. Not sure about future semantics changes:
add_capture_stream() takes a currently unused flags argument, and it
suppresses everything else logged until the stream is removed again.
Signed-off-by: Jan Lindemann <jan@janware.com>
Make log.set_level() return the flags that were set before setting
the flags passed as argument.
Support None as flags argument, in which case it doesn't change
anything and only returns the currently set flags.
Signed-off-by: Jan Lindemann <jan@janware.com>
If module is present in the log flags string, the module is prepended
to each log message. The length of the module prefix can be set via
the new set_module_name_length() function.
Signed-off-by: Jan Lindemann <jan@janware.com>
Run
monkeytype run jw-acc.py --log-level debug db import --format mdb-json-dir dbs
monkeytype list-modules | grep ^jw | while read m; do
monkeytype apply $m
done
and fix the fallout.
Signed-off-by: Jan Lindemann <jan@janware.com>
Fix mypy warning
jwutils/log.py:209: error: Incompatible types in assignment
(expression has type int, variable has type Literal[5])
Signed-off-by: Jan Lindemann <jan@janware.com>
Add only_printable keyword argument to slog(). It defaults to False.
If it's true, non-printable characters are not logged but replaced
with a printable character.
Signed-off-by: Jan Lindemann <jan@janware.com>
In addition to an integer, a string can now be passed, which allows
prefix = ' | '
append_to_prefix(prefix)
slog(INFO, "something")
remove_from_prefix(prefx)
Signed-off-by: Jan Lindemann <jan@janware.com>
Add a kwargs keyword argument. This should allow a kwargs containing
a "caller=" argument to be passed to the function and just do the
right thing. Badly tested.
Signed-off-by: Jan Lindemann <jan@janware.com>
Add type annotations as generated by monkeytype and jw-devops/test, plus some
hand editing to satisfy both monkeytype and mypy.
Signed-off-by: Jan Lindemann <jan@janware.com>
- Add functions: append_to_prefix(),
remove_from_prefix() set_filename_length()
- Make slog_m() log one list item per line
- Add console_color_chars(prio)
Signed-off-by: Jan Lindemann <jan@janware.com>
Add leading underscore to variables that should not be visible
outside of log.py. Also do some indentation beautification.
Signed-off-by: Jan Lindemann <jan@janware.com>
Changes in Python 3 that made the code choke:
o basestring is merged into str
o print() needs parentesis
o Class inheritance syntax changed
o Abstract baseclass (ABCMeta) syntax changed
o map.iteritems() is replaced by map.items()
o Inconsistent use of tabs and spaces are no longer tolerated
Signed-off-by: Jan Lindemann <jan@janware.com>
Arguments to --irrelevant-symbols are not meant to be represented in the
AST resulting from parsing.
Also, add pad() to misc.py.
Signed-off-by: Jan Lindemann <jan@janware.com>