Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Alkorr

    (@alkorr)

    Hi, me again! I checked your github and I’ve seen this code, which in fact does the opposite I’m looking for:

    // Do not log some post types, for example pages and attachments in this case
    add_filter('simple_history/log/do_log', function ($do_log = null, $level = null, $message = null, $context = null, $logger = null) {
    
        $post_types_to_not_log = array(
            'page',
            'attachment',
        );
    
        if (( isset($logger->slug) && ($logger->slug === 'SimplePostLogger' || $logger->slug === 'SimpleMediaLogger') ) && ( isset($context['post_type']) && in_array($context['post_type'], $post_types_to_not_log) )) {
            $do_log = false;
        }
    
        return $do_log;
    }, 10, 5);

    I can’t list all the events I want to be logged because I only want to log 5 events.

    Thanks a lot! ??

    Plugin Author P?r Thernstr?m

    (@eskapism)

    Would this work perhaps?

    
    /**
     * Load only the loggers that are specified in the $do_log_us array.
     */
    add_filter(
        'simple_history/logger/load_logger',
        function ($load_logger, $logger_basename) {
            $load_logger = false;
    
            $do_log_us = [
                'SimpleUserLogger',
                'SimpleMediaLogger',
                'SimplePostLogger',
                'SimpleCategoriesLogger',
                'Plugin_DuplicatePost',
                'SimpleLogger',
            ];
    
            if (in_array($logger_basename, $do_log_us)) {
                $load_logger = true;
            }
    
            return $load_logger;
        },
        10,
        2
    );
    
    Thread Starter Alkorr

    (@alkorr)

    I guess it does, thank you so much! ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Only Log Specific Events’ is closed to new replies.