• Resolved bibberle

    (@bibberle)


    Hi,

    I wrote my own Logger which extends SimpleLogger class and realized it only logs messages which do not exceed 255 chars length. If message length is above 255 chars, it will not be added to the log.

    Therefore, I wrote a function, cutting of any text longer than 252 characters and adding 3 dots at the end.

    Is there any way to log messages longer than 255 characters or does this have SQL reasons?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter bibberle

    (@bibberle)

    Tried to change the field “message” in “simple_history” table directly in my SQL database via phpmyadmin to max allowed chars = 512 and it seems to work. Is this a change I can use or will it produce any problems?

    Plugin Author P?r Thernstr?m

    (@eskapism)

    If I don’t remember incorrectly that’s because a varchar column can not be larger than 255 chars. Well, that was the case for some existing versions of MySQL 5 in 2014 when I added support for loggers in Simple History anyway ??

    255 chars is still pretty long I think. I don’t know how your messages look, but perhaps you could use placeholders and context to store your messages. A value in the context table is of type longtext so they can be like very large as I understand it.

    Something like this:

    <?php
    
    $this->info(
        'Installed version "{version_number}" plugin "{plugin_name}" with another value "{another_context_value}"',
        [
            'version_number' => '1.2',
            'plugin_name' => 'My plugin',
            'another_context_value' => 'This text here can be very long...',
        ]
    );
    

    Your database change should be fine too however.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Log more than 255 characters using SimpleLogger’ is closed to new replies.