log

package module
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 2 Imported by: 6

README

Log

A versatile Go logging wrapper that allows seamless integration and toggling between various logging libraries such as Logrus, Zap, Charmlog and the standard log package. It also supports different logging formats like JSON and text, making it a flexible choice for various application needs.

tag Go Version GoDoc Lint Scan Build Status Go Report Card Contributors License

Installation

To install the LogWrapper package, run the following command:

go get github.com/zcubbs/log

Usage

Here is a simple example demonstrating the usage of LogWrapper with different logging types and formats:

package main

import (
    "github.com/zcubbs/log"
    "github.com/zcubbs/log/structuredlogger"
)

func main() {
    log.Info("This is an info message in JSON format")

    log.SetFormat(structuredlogger.TextFormat)
    log.Info("This is an info message in text format")
}

For a more comprehensive example, please refer to example.go in this repository.

Supported Loggers

Supported Formats

  • JSON
  • Text (Human-Readable)

Contributing

We welcome contributions from the community! Feel free to open issues for bug reports or feature requests, and submit pull requests for improvements to the codebase.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, keysAndValues ...interface{})

func Error

func Error(msg string, keysAndValues ...interface{})

func Fatal

func Fatal(msg string, keysAndValues ...interface{})

func GetLevel added in v0.1.8

func GetLevel() string

func GetLoggerType added in v0.1.8

func GetLoggerType() string

func Info

func Info(msg string, keysAndValues ...interface{})

func SetFormat

func SetFormat(format string)

func SetLevel

func SetLevel(level string)

func SetLogger

func SetLogger(logger Logger)

func SetLoggerType

func SetLoggerType(loggerType string)

func Warn

func Warn(msg string, keysAndValues ...interface{})

Types

type Logger

type Logger interface {
	structuredlogger.StructuredLogger
}

func GetLogger

func GetLogger() Logger

func NewLogger

func NewLogger(loggerType string, name string, format string) Logger

NewLogger is a factory function that creates a new logger based on the given type.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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