in Education by

Is this possible? From what I'm seeing, the only way to get options into the the python class is to hard code them in the python destination's options. I need to set a variable path based on macros like $HOST but python destination options don't seem to be interpolated. I need a way to pass in macro values like $HOST to the init() method. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

Please log in or register to answer this question.

1 Answer

0 votes

The value of $HOST changes for every message, so you actually need it in send(), not in init(). What you might really want is something like this: class MyDestination(object): # ... def send(self, msg): host = msg["HOST"] # ... return True Or you can use templates starting from v3.18: import syslogng class MyDestination(object): def init(self, options): self.log_template = syslogng.LogTemplate("$HOST") # ... return True def send(self, msg): formatted_string = self.log_template.format(msg, self.template_options) # ... return True

Related questions