From Newsgroup: muc.lists.freebsd.stable
Hello,
I have a Python script that writes messages to syslog.
The script works with the print and sleep commands. When I remove the
print and sleep commands, only the first two commands appear in
local5.log file.
=====
#!/usr/bin/env python3.14
import syslog
import os
import sys
import time
FACILITY = syslog.LOG_LOCAL5
def _get_script_name():
return os.path.basename(sys.argv[0])
def LOG_E(message):
script_name = _get_script_name()
formatted_message = f"ERROR: {script_name} {message}"
syslog.openlog(
ident=script_name,
logoption=syslog.LOG_PID,
facility=FACILITY
)
syslog.syslog(syslog.LOG_INFO, formatted_message)
syslog.closelog()
LOG_E("test_e13aaa")
# print("test_e13")
# time.sleep(1)
LOG_E("test_e23")
# print("test_e23")
# time.sleep(1)
LOG_E("test_e33")
# print("test_e33")
# time.sleep(1)
LOG_E("test_e43")
# print("test_e43")
# time.sleep(1)
LOG_E("test_e53")
# print("test_e53")
# time.sleep(1)
LOG_E("test_e63")
# print("test_e63")
# time.sleep(1)
LOG_E("test_e73")
# print("test_e73")
# time.sleep(1)
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to
news-admin@muc.de
--- Synchronet 3.21b-Linux NewsLink 1.2