logging

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

README

logging

A logging library for Apen services

Documentation

Overview

Package logging provides some helper functions to log with context

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Critical

func Critical(ctx context.Context, format string, args ...interface{})

Critical logs a message of critical severity.

func Debug

func Debug(ctx context.Context, format string, args ...interface{})

Debug logs a message of debugging severity.

func Error

func Error(ctx context.Context, format string, args ...interface{})

Error logs a message of error severity.

func Errorw

func Errorw(ctx context.Context, msg string, keysAndValues ...interface{})

Errorw logs a message with additional context

func Finalize

func Finalize()

Finalize finalizes the logging module.

func HTTP

func HTTP(ctx context.Context, req *http.Request, res *http.Response, path string, latency time.Duration)

HTTP is a helper function for logging API request/response

func Info

func Info(ctx context.Context, format string, args ...interface{})

Info logs a message of informational severity.

func Infow added in v0.2.2

func Infow(ctx context.Context, msg string, keysAndValues ...interface{})

Infow logs a message with additional context

func Initialize

func Initialize(c *Config) error

Initialize initializes the logger module.

func RequestLogger

func RequestLogger(excludes []string) gin.HandlerFunc

RequestLogger provides a gin middleware to log HTTP requests

func Warn

func Warn(ctx context.Context, format string, args ...interface{})

Warn logs a message of warning severity.

Types

type Config

type Config struct {
	ProjectID    string `json:"project_id" yaml:"project_id"`
	Level        Level  `json:"level" yaml:"level"`
	Development  bool   `json:"development" yaml:"development"`
	KeyRequestID string `json:"key_request_id" yaml:"key_request_id"`
	KeyUserID    string `json:"key_user_id" yaml:"key_user_id"`
	KeyError     string `json:"key_error" yaml:"key_error"`
	KeyScope     string `json:"key_scope" yaml:"key_scope"`
}

type Level

type Level uint
const (
	LevelFirst Level = iota
	LevelCritical
	LevelError
	LevelWarn
	LevelInfo
	LevelDebug
	LevelLast
)

Jump to

Keyboard shortcuts

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