Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/yayua/kvlog

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/yayua/kvlog

  • v0.0.0-20180223094052-78596401ca74
  • Source
  • Go
  • Socket score

Version published
Created
Source

Key=Value Log Formatter for Logrus

GoDoc Build Status

This package provides a text formatting type for Logrus.
It is similar to the text formatter that comes with Logrus, but is focused on compatibility with logging systems such as Splunk.

It provides a number of features

  • All fields logged as key=value format (which Splunk automatically extracts).
  • Fields keys are sorted into lexicographical order.
  • Important/primary fields can be pinned to the start of each log entry so they're easy to spot.
  • Constant fields can be defined within the formatter. For example, a build commit hash can be included in every log entry automatically.
  • All string types are wrapped in quotes automatically.
  • Types can define their own marshaler for custom behaviour
  • Compound types can return multiple key/value pairs by implementing a Loggable interface.
  • The calling function can optionally be included in every log entry.

Example usage:

log.SetFormatter(
    kvlog.New(
        // include the calling function name
        kvlog.IncludeCaller(), 

        // ensure action and status always appear first
        kvlog.WithPrimaryFields("action", "status")))

log.WithFields(log.Fields{
    "action":          "user_login",
    "status":          "ok",
    "username":        "joe_user",
    "email":           "joe@example.com",
    "active_sessions": 4,
}).Info("User logged in")

// Output:
//  2017-01-02T12:00:00.000Z ll="info" srcfnc="Example" srcline=29 action="user_login" status="ok" active_sessions=4 email="joe@example.com" username="joe_user" _msg="User logged in"

FAQs

Package last updated on 23 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc