Categorygithub.com/best-expendables-v2/logger
modulepackage
0.0.0-20231009083951-d43d9d821b65
Repository: https://github.com/best-expendables-v2/logger.git
Documentation: pkg.go.dev

# README

logger GO library

Install

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

Rules:

Message is truncated at 128 characters

Level table

Priority#1#2#3#4#5#6#7#8
Levelemergalertcriterrwarningnoticeinfodebug

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-v2/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-v2/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-v2/logger"
    )
    
    func main() {
    	logger.Info("Test log")
    }

# Packages

No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
ContextWithEntry set entry to context.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
EntryFromContext get entry from context.
EntryFromContextOrDefault returns the logger from context if not nil, otherwise, returns default entry.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewLoggerProvider returns logger provider.
No description provided by the author
No description provided by the author
SetDefaultEntry.
SetOut output log writer.
No description provided by the author
No description provided by the author
WithFields returns copy of default entry with fields.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
FormatVersion log format version.
No description provided by the author
MessageLength max length of message.
No description provided by the author
No description provided by the author

# Structs

No description provided by the author

# Interfaces

Entry
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author