Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging binary data #64

Open
remoosey opened this issue May 21, 2017 · 0 comments
Open

Logging binary data #64

remoosey opened this issue May 21, 2017 · 0 comments

Comments

@remoosey
Copy link

remoosey commented May 21, 2017

I stumbled upon that adding binary data to the log makes the header added be completely blank. Turns out it dies on the json_encode of binary data. The easy fix was to utf8_encode it:
`
protected static function _log($type, array $args)
{
// nothing passed in, don't do anything
if (count($args) == 0 && $type != self::GROUP_END) {
return;
}

    $logger = self::getInstance();

    $logger->_processed = array();

    $logs = array();
    foreach ($args as $arg) {
        $logs[] = $logger->_convert(utf8_encode($arg)); //added to fix logging binary data
    }
    
    $backtrace = debug_backtrace(false);
    $level = $logger->getSetting(self::BACKTRACE_LEVEL);

    $backtrace_message = 'unknown';
    if (isset($backtrace[$level]['file']) && isset($backtrace[$level]['line'])) {
        $backtrace_message = $backtrace[$level]['file'] . ' : ' . $backtrace[$level]['line'];
    }

    $logger->_addRow($logs, $backtrace_message, $type);
}

`

Should probably be done for the other logging alias methods (error, warn, etc).
Should I do a pull request with this? Seems very minor. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant