项目作者: vardius

项目描述 :
Go logger
高级语言: Go
项目地址: git://github.com/vardius/golog.git
创建时间: 2016-07-18T08:59:16Z
项目社区:https://github.com/vardius/golog

开源协议:MIT License

下载


📟 golog

Build Status
Go Report Card
codecov

license

logo

golog - Logger

📖 ABOUT

Contributors:

Want to contribute ? Feel free to send pull requests!

Have problems, bugs, feature ideas?
We are using the github issue tracker to manage them.

📚 Documentation

For examples visit godoc#pkg-examples

For GoDoc reference, visit pkg.go.dev

🚏 HOW TO USE

🏫 Basic example

  1. package main
  2. import (
  3. "fmt"
  4. "context"
  5. "github.com/vardius/golog"
  6. )
  7. func main() {
  8. ctx := context.Background()
  9. logger := golog.New()
  10. logger.Debug(ctx context.Context, fmt.Sprintf("Hello %s!", "you"))
  11. }

📦 As a package

  1. package mylogger
  2. import (
  3. "context"
  4. "github.com/vardius/golog"
  5. )
  6. var Logger golog.Logger
  7. func SetFlags(flag int) {
  8. Logger.SetFlags(flag)
  9. }
  10. func SetVerbosity(verbosity golog.Verbose) {
  11. Logger.SetVerbosity(verbosity)
  12. }
  13. func Debug(ctx context.Context, v string) {
  14. Logger.Debug(ctx, v)
  15. }
  16. func Info(ctx context.Context, v string) {
  17. Logger.Info(ctx, v)
  18. }
  19. func Warning(ctx context.Context, v string) {
  20. Logger.Warning(ctx, v)
  21. }
  22. func Error(ctx context.Context, v string) {
  23. Logger.Error(ctx, v)
  24. }
  25. func Critical(ctx context.Context, v string) {
  26. Logger.Critical(ctx, v)
  27. }
  28. func Fatal(ctx context.Context, v string) {
  29. Logger.Fatal(ctx, v)
  30. }
  31. func init() {
  32. Logger = golog.New()
  33. }

usage:

  1. package main
  2. import (
  3. "fmt"
  4. "mylogger"
  5. )
  6. func main() {
  7. mylogger.Debug(ctx context.Context, fmt.Sprintf("Hello %s!", "you"))
  8. }

📜 License

This package is released under the MIT license. See the complete license in the package