def test_filter_multiple_reference(config, syslog_ng): config.update_global_options(keep_hostname="yes") file_source = config.create_file_source(file_name="input.log") file_src_group = config.create_statement_group(file_source) negated_filter = config.create_statement_group( config.create_filter("not (program('noprog') and message('nomsg'))")) file_destination1 = config.create_file_destination(file_name="output1.log") file_destination2 = config.create_file_destination(file_name="output2.log") config.create_logpath( statements=[file_src_group, negated_filter, file_destination1]) config.create_logpath( statements=[file_src_group, negated_filter, file_destination2]) log_msg = LogMessage().program("PROGRAM").message("MESSAGE") bsd_msg = BSDFormat.format_message(log_msg.remove_priority()) file_source.write_log(bsd_msg) syslog_ng.start(config) dest1_logs = file_destination1.read_logs(counter=1) assert bsd_msg in dest1_logs dest2_logs = file_destination2.read_logs(counter=1) assert bsd_msg in dest2_logs
def write_msg_with_fields(file_source, bsd_formatter, hostname): log_message = LogMessage().hostname(hostname) input_message = bsd_formatter.format_message(log_message) expected_message = bsd_formatter.format_message( log_message.remove_priority()) file_source.write_log(input_message) return expected_message
def create_dummy_message(): log_message = LogMessage() log_message.priority_value = "38" log_message.timestamp_value = time.time() log_message.hostname_value = socket.gethostname() log_message.program_value = "testprogram" log_message.pid_value = "9999" log_message.message_value = "test message" return log_message
def log_message(): return LogMessage()
def write_msg_with_fields(file_source, bsd_formatter, hostname, program): log_message = LogMessage().hostname(hostname).program(program) input_message = bsd_formatter.format_message(log_message) expected_message = bsd_formatter.format_message(log_message.remove_priority()) file_source.write_log(input_message) return expected_message
def new_log_message(): return LogMessage()