• Resolved ckaklamanos

    (@ckaklamanos)


    Hello

    First of all, this an awesome plugin and one of my favorite plugins. I use it on almost all the websites that I develop.

    So, here is my issue:

    I am working on a site where I want to log every time the WP Cron runs (in our case it runs every 10 minutes). The logs are written properly but they are not being grouped based on the “_occasionsID” that I have used. So, my Simple History log is flooded by this same log entry.

    I know from other cases that “_occasionsID” has worked for me.

    Can you help me understand what I may be doing wring in this case?

    Thanks.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter ckaklamanos

    (@ckaklamanos)

    Hello.

    I wanted to follow up on this issue.

    Any clues?

    Thank you in advance.

    Plugin Author eskapism

    (@eskapism)

    Hey @ckaklamanos, I’m on vacation at the moment, but will take a look at this next week when I’m back.

    Plugin Author eskapism

    (@eskapism)

    @ckaklamanos What database server and version are you using on the website where it’s not working? MySQL or MariaDB? I have a theory that it may be related to some combination for server and version..

    Thread Starter ckaklamanos

    (@ckaklamanos)

    Hello and thank you very much for getting back.

    Here is the information from WordPress health screen:

    Database
    Extension mysqli
    Server version 10.3.35-MariaDB-1:10.3.35+maria~focal-log
    Database collation utf8mb4_general_ci

    Server
    Web server Apache/2.4.41 (Ubuntu)
    PHP version 8.0.26 (Supports 64bit values)

    Thank you in avdance.

    Plugin Author eskapism

    (@eskapism)

    How do you add your entries to the log?

    I did test this now, on both MySQL and MariaDB and it did work:

    
        $context = array(
            '_occasionsID' => 'my_custom_occasions_id',
        );
    
        // First occasion.
        SimpleLogger()->notice(
            'Custom message with custom occasions notice 1',
            $context
        );
    
        SimpleLogger()->notice(
            'Custom message with custom occasions, notice 2',
            $context
        );

    In the history feed the above works and only the first message is shown for me, with an option to expand to show the second message.

    Thread Starter ckaklamanos

    (@ckaklamanos)

    Hello and again, thanks for getting back.

    This is how I always do it, with the filter:

        // Simple History
        apply_filters(
            'simple_history_log',
            'XYZ: WP Cron Completed',
            [
                '_occasionsID' => 'xyz_wp_cron_completed_log',
            ],
            'debug'
        );

    I am using the above filter in order to log the “WP Cron completed” task.

    Also, I am running the above filter inside an MU plugin. However, this should not be relevant, because I have the same issue with using the same filter inside a standard plugin.

    Thank you.

    Plugin Author eskapism

    (@eskapism)

    I just tried your code and it worked perfectly. I called it 10 times and this was the result:

    Is there nothing else being logged between your cron events, like a user logging in or a post being edited or something? For the grouping to work there can’t be anything else being logged between.

    Thread Starter ckaklamanos

    (@ckaklamanos)

    Hello.

    It looks like you are right. I was not aware of that.

    Indeed, there are various log entries that are inserted in the time between the cron logs.

    Thanks for help me with this and sorry for the misunderstanding of how this works.

    Plugin Author eskapism

    (@eskapism)

    No worries, just happy that we found out what was the cause of this.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Using “_occasionsID” does not group the logs, they still show separately’ is closed to new replies.