log

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2021 License: MIT Imports: 5 Imported by: 1

README

Log

FluentdFormatter

Useful addition to logrus, allowing it to format log entries that can be parsed by Kubernetes and Google Container Engine.

Example:

package main

import (
	"os"
	"fmt"
	"flag"

	log "github.com/sirupsen/logrus"
	joonix "github.com/joonix/log"
)

func main() {
	lvl := flag.String("level", log.DebugLevel.String(), "log level")
	flag.Parse()

	level, err := log.ParseLevel(*lvl)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	log.SetLevel(level)
	log.SetFormatter(&joonix.FluentdFormatter{})

	log.Debug("hello world!")		
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SeverityMap = map[string]string{
	"panic":   "fatal",
	"fatal":   "fatal",
	"warning": "warn",
	"debug":   "debug",
	"error":   "error",
	"trace":   "trace",
	"info":    "info",
}

Default logrus to FluentD severity map

Functions

func UseStackdriverSeverity

func UseStackdriverSeverity()

logrus to stackdriver severity map

Types

type FluentdFormatter

type FluentdFormatter struct {
	TimestampFormat string
	SeverityMap     map[string]string
}

FluentdFormatter is similar to logrus.JSONFormatter but with log level that are recongnized by kubernetes fluentd.

func (*FluentdFormatter) Format

func (f *FluentdFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format the log entry. Implements logrus.Formatter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL