# --echo # --echo # WL#9343: log TNG: log writers --echo # --echo # --echo # This test verifies the interaction with the 'ix syslog. --echo # It is disabled by default, to be run manually, so we --echo # won't spam the test host's syslog on a regular and concurrent --echo # basis. Besides, we'd have to make an unpleasant amount of --echo # assumptions about where the logs are located, how they're structured, --echo # and that we had the privileges to access them. --echo # This test is therefore provided for convenience, but disabled by --echo # default, and is not expect to pass on all platforms. --echo # # on systemd systems: journalctl SYSLOG_IDENTIFIER=mysqld-wl9343 # on syslog systems: grep mysqld-wl9343 /var/log/messages|cut -d: -f4- --source include/have_debug.inc --source include/linux.inc --source include/have_log_component.inc let GREP_START=`SELECT DATE_FORMAT(CONVERT_TZ(SYSDATE(6),'SYSTEM','UTC'),'%Y%m%d%H%i%s%f');`; SET @@global.log_error_verbosity=3; let $log_error_= `SELECT @@GLOBAL.log_error`; if($log_error_ == "stderr") { let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.1.err; } FLUSH LOGS; # Send parse-trace to error log; first one with a current timestamp # to compare against our GREP_START defined above. SET @@session.debug="+d,parser_stmt_to_error_log"; # Now normalize timestamp and thread_ID on all following lines, # for less hassle with --regex_replace in test files. Once # WL#9651 goes live, we can use that to achieve the same thing. SET @@session.debug="+d,log_error_normalize"; # Log parser statement with System label too. SET @@session.debug="+d,parser_stmt_to_error_log_with_system_prio"; SELECT @@global.log_error_services; --echo # Component not loaded, variable not present --error ER_UNKNOWN_SYSTEM_VARIABLE SELECT @@syseventlog.tag; SELECT "*** SWITCHING ERROR LOG TO SYSEVENTLOG ***"; INSTALL COMPONENT "file://component_log_sink_syseventlog"; --echo # default value SELECT @@global.syseventlog.tag; --echo # change tag SET @@global.syseventlog.tag="wl9343"; SELECT @@global.syseventlog.tag; SET @@global.log_error_services="log_filter_internal; log_sink_internal; log_sink_syseventlog"; SELECT "logging to syslog"; --echo # change while component is active SET @@global.syseventlog.tag="wl9343_2"; SELECT @@global.syseventlog.tag; SET @@global.log_error_services="log_filter_internal; log_sink_internal"; --echo # change while component is loaded, but inactive SET @@global.syseventlog.tag=DEFAULT; SELECT @@global.syseventlog.tag; # Check that SET PERSIST retains variable values # --------------------------------------------------------- SET PERSIST syseventlog.include_pid = OFF; SET PERSIST syseventlog.facility = "local1"; SET PERSIST syseventlog.tag = "wl11828"; --let $log_services="log_filter_internal;log_sink_syseventlog;log_sink_internal" --let restart_parameters="restart: --no-console --log-error-services=$log_services " --source include/restart_mysqld.inc # Verify value of the persisted variable SELECT @@syseventlog.include_pid; SELECT @@syseventlog.facility; SELECT @@syseventlog.tag; RESET PERSIST `syseventlog.include_pid`; RESET PERSIST `syseventlog.facility`; RESET PERSIST `syseventlog.tag`; --echo # Verify that we accept arguments passed at start-up --let $log_services="log_filter_internal;log_sink_syseventlog;log_sink_internal" --let restart_parameters="restart: --no-console --log-error-services=$log_services --syseventlog.include_pid=OFF --syseventlog.facility=local2 --syseventlog.tag=wl11828_2 " --source include/restart_mysqld.inc # Verify value of the persisted variable SELECT @@syseventlog.include_pid; SELECT @@syseventlog.facility; SELECT @@syseventlog.tag; # Verify that we use default settings if invalid arguments are passed # at start-up --let LOG_FILE= $MYSQLTEST_VARDIR/tmp/wl11828.err --let $log_services="log_filter_internal;log_sink_syseventlog;log_sink_internal" --let restart_parameters="restart: --no-console --log-error=$LOG_FILE --log-error-services=$log_services --syseventlog.include_pid=PIKA --syseventlog.facility=localZ --syseventlog.tag=wl11828/2 " --replace_result $LOG_FILE LOG_FILE --source include/restart_mysqld.inc # Verify value of the persisted variable SELECT @@syseventlog.include_pid; SELECT @@syseventlog.facility; SELECT @@syseventlog.tag; # Cleanup SET GLOBAL log_error_services= default; --echo --echo # cleanup # UNINSTALL COMPONENT "file://component_log_syseventlog"; SET @@session.debug="-d,parser_stmt_to_error_log_with_system_prio"; SET @@session.debug="-d,parser_stmt_to_error_log"; SET @@session.debug="-d,log_error_normalize"; ## WL#9651 # SET @@global.log_error_filter_rules=@save_filters; FLUSH ERROR LOGS; --perl use strict; use JSON; my $file= $ENV{'LOG_FILE'} or die("logfile not set"); my $result=0; open(FILE, "$file") or die("Unable to open $file: $!"); while () { my $line = $_; if ($line =~ /syseventlog\./) { $line =~ s/.*\]//; print $line; } } close(FILE); EOF --remove_file $LOG_FILE --echo --echo ### --echo ### done --echo ###