Skip to content

brettcodling/jsonlogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

JsonLogger Go Report Card

A Go (golang) json logging library for use with GCP Logs Explorer

Installation

As a library

go get github.com/brettcodling/jsonlogger

Usage

package main

import github.com/brettcodling/jsonlogger"

func main() {
  // You can use the built in log level methods (Info, Debug, Warn, Error)
  jsonlogger.Info("Info level log")
  
  // You can pass a context interface to the log as long as it can be marshalled to json
  err := ...
  jsonlogger.Error("Error!!!", map[string]string{"error": err.Error()})
  
  // You can also manually populate the JsonLog struct and call Log()
  jsonlogger.JsonLog{
    Message:  "Manual log",
    Context:  map[string]int{"test": 1}
    Severity: "INFO",
    Type:     "log",
  }.Log()
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages