Skip to content

Rafay106/jsonlogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON Logger

A reusable structured logger package built on zerolog with hourly file rotation, optional stdout/file output, and retention cleanup. It is optimized for Grafana-style filtering using project, appId, and serverId fields.

Usage

import "github.com/Rafay106/jsonlogger"

func main() {
    log, err := jsonlogger.New(jsonlogger.Config{
        Level:         "info",
        Dir:           "logs",
        Project:       "geonavi",
        AppID:         "gps-parser",
        ServerID:      "instance-1",
        RetentionDays: 7,
        EnableStdout:  true,
        EnableFile:    true,
    })
    if err != nil {
        panic(err)
    }
    defer log.Close()

    jsonlogger.Log.Info().Msg("starting application")
}

Notes

  • Use the global jsonlogger.Log instance for structured logging across packages.
  • Configure Project, AppID, and ServerID for app/server-level log filtering.
  • Set EnableStdout or EnableFile to control output destinations.
  • Update the module path in go.mod to your repository path before publishing.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages