python-fetcher() Source Driver
The python-fetcher() 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-fetcher(
class("TestPython")
);
};
python {
from syslogng import LogFetcher
from syslogng import LogMessage
class TestPython(LogFetcher):
def fetch(self): # mandatory
# return LogFetcher.FETCH_ERROR,
# return LogFetcher.FETCH_NOT_CONNECTED,
# return LogFetcher.FETCH_TRY_AGAIN,
# return LogFetcher.FETCH_NO_DATA,
return (LogFetcher.FETCH_SUCCESS, "Message from Python-Fetcher Source")
def request_exit(self):
print("request_exit")
# If your fetching method is blocking, do something to break it
# For example, if it reads a socket: socket.shutdown()
};
log {
source(s_python);
destination(console);
};Proof


Last updated