• Resolved Alkorr

    (@alkorr)


    Hi! I just installed this plugin and it seems to work perfectly so far! I have a question though: I would like to only log a couple of events:

      SimpleLogger (mandatory, I guess)
      SimpleUserLogger
      SimpleMediaLogger
      SimplePostLogger
      SimpleCategoriesLogger
      Plugin_DuplicatePost

    I checked the forum before posting and I found this thread: https://wordpress.org/support/topic/i-dont-want-to-track-plugin-and-theme-updates-how-not-to-log-those/

    Unfortunately I don’t know if it’s possible to only log these specific events and how to add more events to the function. If someone can help me, that would be great! 🙂

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.