logging

package module
v0.0.0-...-e989fc7 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: Apache-2.0 Imports: 5 Imported by: 4

README

Go Logging library

A library that supports the formatting of log messages to fit with the 4S-microservice logging style.

This library can be used in collaboration with tools like fluentd and Kibana.

Project wiki

See: Main.md

Project status

4S maturity level: prototyping.

Prerequisites

You need to have the following software installed

Go (golang) (https://golang.ir/) librdkafka (https://github.com/confluentinc/confluent-kafka-go#installing-librdkafka)

Building:

This library does not contain a main package, and therefore cannot be built on its own.

Usage

To use this library, it must be included in a project containing a main-package.

To include this library run the following command in your terminal/shell:

go get "bitbucket.org/4s/go-logging"

After retrieving the library, the library can be included by importing it, in the files in which it is required:

package ...
import (
  ...
  log "bitbucket.org/4s/go-logging"
)
...
ctx := context.Background()
log.WithContext(ctx).Infof("%v started", serviceName)
...

Environment variables

The files service.env contains the environment variables that you can use if you include and use this library in you own services.

LOG_LEVEL_DK_S4 specifies the log level of the service. The available log levels are (in descending order of severity):

panic
fatal
error
warning
info
debug
trace

LOGGER_NAME is the name of the logger. This will be added as a field ("logger_name") in the output from each log-statement

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, fields logrus.Fields) context.Context

NewContext returns a context that has a logger with the extra fields added

func WithContext

func WithContext(ctx context.Context) *logrus.Entry

WithContext returns a logger with as much context as possible

Types

This section is empty.

Jump to

Keyboard shortcuts

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