Skip to content

Missing Columns on Custom Formatter #305

Answered by arukompas
jfvoliveira asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @jfvoliveira , glad you're experimenting with custom logs!

So, I'm not sure if I missed it in the docs or not, but it's not enough to just provide extra regex named groups. You should also update the fillMatches() method that you mentioned above, to something like this:

protected function fillMatches(array $matches = []): void
{
    // the parent method only parses datetime, level, and message
    parent::fillMatches($matches);
    
    // for other properties, fill them in $this->context or $this->extra
    $this->context = [
        'env' => $matches['env'] ?? '',
        'code' => $matches['code'] ?? '',
        'payload' => json_decode($matches['payload'] ?? 'null'),
    ];
    
    

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@jfvoliveira
Comment options

@arukompas
Comment options

@jfvoliveira
Comment options

@arukompas
Comment options

@jfvoliveira
Comment options

Answer selected by arukompas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants