Categorygithub.com/cguertin14/logger
modulepackage
1.0.6
Repository: https://github.com/cguertin14/logger.git
Documentation: pkg.go.dev

# README

logger

Simple Go logger using contexts.

Installation

$ go get github.com/cguertin14/logger

Usage

package main

import (
	"context"

	"github.com/cguertin14/logger"
)

func main() {
	ctx := context.Background()

	// Initialize logger
	ctxLogger := logger.Initialize(logger.Config{
		Level: "info",
	})

	// Put logger instance in context
	ctx = context.WithValue(ctx, logger.CtxKey, ctxLogger)

	// Fetch logger from context
	foundLogger := logger.NewFromContextOrDefault(ctx)
	foundLogger.Info("hey there")
}

# Packages

No description provided by the author

# Functions

Initialize - Initializes a new Logger from a given configuration.
NewFromContextOrDefault - Returns a Logger from a given Context instance.

# Constants

CtxKey - The context key for the Logger instance.

# Variables

CLIFormatter Default fomatter for CLIs such as tools used on local machines.
ServiceFormatter Default formatter for online services such as microservices.

# Structs

Config - The configuration used by a Logger.