319d97e8bc
log.py: Fix mypy warning (Incompatible types in assignment)
...
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>
2022-10-04 13:11:44 +02:00
8029b672bf
slog(): Add only_printable keyword argument
...
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>
2020-05-16 15:33:13 +00:00
4a047ca260
log.remove_from_prefix(): Add support for str argument
...
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>
2020-04-23 10:32:05 +02:00
5924ec9769
log.get_caller_pos(): Add kwargs argument
...
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>
2020-04-11 10:56:30 +02:00
77d43aebad
Add type annotations from monkeytype + jw-devops/test
...
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>
2020-04-10 17:55:36 +02:00
79ebb798c7
slog_m(): Support kwarg "caller"
...
Treat slog_m() to a caller keyword argument, up to now only supported by slog().
Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-04 11:12:11 +02:00
08f9aae61a
log.get_caller_pos(): Implement frames > 1
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2019-12-30 17:46:20 +01:00
26d322023a
log.py: Improve console color implementation
...
o Remove unnecessary function prio_colors() o Don't output color codes on non-TTY output
Signed-off-by: Jan Lindemann <jan@janware.com>
2019-12-23 18:01:53 +01:00
2171e1e16e
log.py: Add support for flag "date"
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2019-12-21 19:08:51 +00:00
d3faa8ee85
log.py: Add utilities, better list-support in slog_m()
...
- 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>
2019-10-30 15:46:26 +01:00
036a978130
log.py: Add slog_m() (multiline logging)
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2019-10-28 12:50:17 +01:00
1cdb38b767
log.py: Make some variables private
...
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>
2019-10-28 10:59:20 +01:00
6dd594d47b
Fix multiple Python 3 compatibility issues
...
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>
2019-03-10 16:38:59 +01:00
8c5934725c
grammar.py: Add support for --irrelevant-symbols
...
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>
2017-10-30 10:00:25 +01:00
860f7d8cab
Implement caller keyword argument to slog()
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-10-27 18:58:53 +02:00
4e3a6630da
log.py: Add set_flags()
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-10-25 10:06:29 +02:00
d15242600a
log.py: Fix non-working slog()
...
No idea how this ever worked. Still not sure about the best way.
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-10-16 12:22:49 +02:00
0aecc8d076
Make jwutils.log module somewhat usable
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-08-07 18:05:53 +02:00
36aac73b5d
Add Object.py and log.py
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-07-30 18:51:19 +02:00