mirror of
https://codeberg.org/privacy1st/de-p1st-monitor
synced 2024-12-22 23:06:06 +01:00
fix: journald compatible log level
This commit is contained in:
parent
ba358d244e
commit
b9832d0b24
@ -3,7 +3,7 @@
|
||||
|
||||
[metadata]
|
||||
name = de.p1st.monitor
|
||||
version = 0.11.4
|
||||
version = 0.11.5
|
||||
author = Daniel Langbein
|
||||
author_email = daniel@systemli.org
|
||||
description = periodically monitor and warn
|
||||
|
@ -15,32 +15,38 @@ import sys
|
||||
# define SD_DEBUG "<7>" /* debug-level messages */
|
||||
|
||||
def print_emerg(message: object):
|
||||
print(f'<0> {message}', file=sys.stderr)
|
||||
do_print('<0> ', message, file=sys.stderr)
|
||||
|
||||
|
||||
def print_alert(message: object):
|
||||
print(f'<1> {message}', file=sys.stderr)
|
||||
do_print('<1> ', message, file=sys.stderr)
|
||||
|
||||
|
||||
def print_crit(message: object):
|
||||
print(f'<2> {message}', file=sys.stderr)
|
||||
do_print('<2> ', message, file=sys.stderr)
|
||||
|
||||
|
||||
def print_err(message: object):
|
||||
print(f'<3> {message}', file=sys.stderr)
|
||||
do_print('<3> ', message, file=sys.stderr)
|
||||
|
||||
|
||||
def print_warning(message: object):
|
||||
print(f'<4> {message}', file=sys.stderr)
|
||||
do_print('<4> ', message, file=sys.stderr)
|
||||
|
||||
|
||||
def print_notice(message: object):
|
||||
print(f'<5> {message}', file=sys.stdout)
|
||||
do_print('<5> ', message)
|
||||
|
||||
|
||||
def print_info(message: object):
|
||||
print(f'<6> {message}', file=sys.stdout)
|
||||
do_print('<6> ', message)
|
||||
|
||||
|
||||
def print_debug(message: object):
|
||||
print(f'<7> {message}', file=sys.stdout)
|
||||
do_print('<7> ', message)
|
||||
|
||||
|
||||
def do_print(line_prefix: str, message: object, file=sys.stdout) -> None:
|
||||
# Prefix each line in str(object) with `line_prefix`.
|
||||
prefixed = line_prefix + str(message).replace('\n', '\n' + line_prefix)
|
||||
print(prefixed, file=file)
|
||||
|
Loading…
Reference in New Issue
Block a user