logger

package module
v0.0.0-...-6aabb59 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

log-zap

Go Reference License Release Go Test Go Report Card

log-zap is wrapper of go.uber.org/zap for log

Usage

package main

import (
    "log"

    hlog "github.com/go-haru/log"

    logger "github.com/go-haru/log-zap"
)

func main() {
    var config = logger.Options{
        Level:     hlog.InfoLevel.String(),
        Format:    logger.FormatText,
        LongTime:  true,
        WithColor: true,
    }

    // build wrapped zap logger
    var zapLogger, err = logger.New(config)
    if err != nil {
        panic(err)
    }

    // register logger
    hlog.Use(zapLogger)

    // takeover sdk logger's output 
    log.SetFlags(0)
    log.SetOutput(zapLogger.
        WithLevel(hlog.InfoLevel).
        AddDepth(-1).
        Standard().Writer(),
    )
}

Contributing

For convenience of PM, please commit all issue to Document Repo.

License

This project is licensed under the Apache License Version 2.0.

Use and contributions signify your agreement to honor the terms of this LICENSE.

Commercial support or licensing is conditionally available through organization email.

Documentation

Index

Constants

View Source
const (
	FormatJSON = "json"
	FormatText = "text"
)

Variables

This section is empty.

Functions

func New

func New(opts Options) (_ log.Logger, err error)

Types

type Options

type Options struct {
	Level     string `json:"level" yaml:"level"`
	Format    string `json:"format" yaml:"format"`
	LongTime  bool   `json:"longTime" yaml:"longTime"`
	WithColor bool   `json:"withColor" yaml:"withColor"`
}

Jump to

Keyboard shortcuts

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