Skip to content

StdLibAdapter can not extract log line with set prefix correctly #1035

@soven

Description

@soven

When using a prefix in stdlib's logger StdLibAdapter extracts the fields from log line incorrectly.

For example, the program

package main

import (
    "log"
    "os"

    gokitlog "github.com/go-kit/kit/log"
)

func main() {
    logg := log.New(gokitlog.NewStdlibAdapter(gokitlog.NewLogfmtLogger(os.Stdout)),
        "some prefix ", log.LstdFlags)
    logg.Println("log line")
}

will give us the following to the stdout:

caller="some prefix 2020/11/16 22:33" msg=":04 log line"

I have a fix to support the prefix mode by adding a method Prefix(prefix string, joinPrefixToMsg bool) StdlibAdapterOption

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions