Closed szepeviktor closed 8 years ago
@bonny Could you help me? Even a work-around would help. This is a handmade WAF of mine, it's a MU plugin.
Sorry for not getting back sooner... I have had similar problems myself when I wanted to log things that happened early in other plugins. I do init the loggers late because I wanted everything to be possible to filter in a themes functions.php-file.
I need to think about this for a bit I'm afraid.
Cloud I initialize Simple History in my own (early) muplugin?
It seem like working:
// Send to Simple History
if ( function_exists( 'SimpleLogger' ) ) {
$simple_level = $this->translate_apache_level( $level );
$context = array(
'_security' => "WordPress fail2ban",
'_server_request_method' => $this->esc_log( $_SERVER['REQUEST_METHOD'] )
);
if ( array_key_exists( 'HTTP_USER_AGENT', $_SERVER ) ) {
$context['_server_http_user_agent'] = $this->esc_log( $_SERVER['HTTP_USER_AGENT'] );
}
// HERE is the actual work-around
if ( ! class_exists( 'SimpleLogger' ) ) {
SimpleHistory::get_instance()->load_loggers();
}
SimpleLogger()->log( $simple_level, $error_msg, $context );
}
@bonny Please consider including it in the FAQ.
Simple-History loads after the theme: https://github.com/bonny/WordPress-Simple-History/blob/e7ced9a24d338a3771a2a1b2272fd83898118ece/inc/SimpleHistory.php#L91
I call
if ( function_exists( 'SimpleLogger' ) ) {SimpleLogger()->log();}
at plugins_loaded, and have a Fatal:PHP Fatal error: Class 'SimpleLogger' not found in */wp-content/plugins/simple-history/inc/SimpleHistory.php on line 2851
https://github.com/szepeviktor/wordpress-fail2ban/blob/master/mu-plugin/wp-fail2ban-mu-instant.php#L201-L212
Please advise.