python() Source Driver
The Python source allows you to write your own source in Python. You can import external Python modules to receive or fetch the messages.
Important Information
Status
Configuration File Used
@version: 3.33
@include "scl.conf"
destination console{
file(/dev/stdout);
};
source s_python{
python(
class("TestPython")
options(
"option1" "value1",
"option2" "value2"
)
);
};
python {
from syslogng import LogSource
from syslogng import LogMessage
import time
class TestPython(LogSource):
def init(self, options): # optional
print("init")
print(options)
self.exit = False
return True
def deinit(self): # optional
print("deinit")
def run(self): # mandatory
print("run")
while not self.exit:
# Must create a message
msg = LogMessage("this is a log message from Python Source")
self.post_message(msg)
time.sleep(1)
def request_exit(self): # mandatory
print("exit")
self.exit = True
};
log {
source(s_python);
destination(console);
};Proof


Last updated