logger

package module
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: MIT Imports: 5 Imported by: 0

README

Logger for Golang

It is based on the zap package.

Install

go get github.com/dollarsignteam/go-logger

Usage

package main

import (
  "github.com/dollarsignteam/go-logger"
)

func main() {
  opts := logger.LoggerOptions{
    Level:      "debug",
    Name:       "DEMO",
    HideCaller: false,
  }
  log := logger.NewLogger(opts)
  log.Debug("I am a debug log")
  log.Info("I am a info log")
  log.Warn("I am a warn log")
  log.Error("I am a error log")
}

Output

2022-02-03 22:49:44.933 +07:00 [go] 🟪 DEBUG  [DEMO] [main.go:14 main.main] I am a debug log
2022-02-03 22:49:44.934 +07:00 [go] ⬜️ INFO   [DEMO] [main.go:15 main.main] I am a info log
2022-02-03 22:49:44.934 +07:00 [go] 🟧 WARN   [DEMO] [main.go:16 main.main] I am a warn log
2022-02-03 22:49:44.934 +07:00 [go] 🟥 ERROR  [DEMO] [main.go:17 main.main] I am a error log

Author

Dollarsign

License

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 ToLevel

func ToLevel(level string) zapcore.Level

Types

type Logger

type Logger struct {
	*zap.SugaredLogger
}

func NewLogger

func NewLogger(opts LoggerOptions) *Logger

type LoggerOptions

type LoggerOptions struct {
	Level      string
	Name       string
	HideCaller bool
}

Jump to

Keyboard shortcuts

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