Skip to content

best-expendables/logger

Repository files navigation

logger GO library

Install

import:
- package: github.com/best-expendables/logger
  version: x.x.x

Rules:

Message is truncated at 128 characters

Level table

Priority #1 #2 #3 #4 #5 #6 #7 #8
Level emerg alert crit err warning notice info debug

There are 8 Levels to provide to LoggerProvider

EmergencyLevel
AlertLevel
CriticalLevel
ErrorLevel
WarningLevel
NoticeLevel
InfoLevel
DebugLevel

Examples:

With content field
    
	package main
    
    import (
        "github.com/best-expendables/logger"
    	"context"
    )
    
    func main() {
        // Create loggerFactory with level Error above
        loggerFactory := logger.NewLoggerFactory(logger.ErrorLevel)

        // fake context,
        // in real cases, it should be current app's context
        ctx := context.TODO()
    
        // withField will be filled into "content" field
        loggerFactory.Logger(ctx).WithField("test key", "test").Alert("Test")
    
        // simple log, no content field
        loggerFactory.Logger(ctx).Debug("Testing")
        loggerFactory.Logger(ctx).Critical("Testing")
        loggerFactory.Logger(ctx).Error("Testing")
        loggerFactory.Logger(ctx).Warning("Testing")
        loggerFactory.Logger(ctx).Notice("Testing")
    }
Without content field
     package main
     
     import (
     	"github.com/best-expendables/logger"
     	"context"
     )
     
     func main() {
        // Create loggerFactory with level Error above
        loggerFactory := logger.NewLoggerFactory(logger.ErrorLevel)

        
        // fake context,
        // in real cases, it should be current app's context
        ctx := context.TODO()
    
        // simple log, no content field
        loggerFactory.Logger(ctx).Debug("Testing")
        loggerFactory.Logger(ctx).Critical("Testing")
        loggerFactory.Logger(ctx).Error("Testing")
        loggerFactory.Logger(ctx).Warning("Testing")
        loggerFactory.Logger(ctx).Notice("Testing")
     }
simple log without any fields
    
	package main
    
    import (
    	"github.com/best-expendables/logger"
    )
    
    func main() {
    	logger.Info("Test log")
    }

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages