Skip to content

choveylee/tlog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tlog

tlog provides structured logging for Go applications on top of zerolog. It integrates with tcfg for configuration, ttrace for trace propagation, optional rotating file output, and optional Sentry reporting for error-level events.

Capabilities

  • Process-wide default logger configured during package initialization
  • Structured leveled logging through D, I, W, E, F, and P
  • Optional detail and error fields through Detail, Detailf, and Err
  • Automatic trace_id injection from context.Context when a valid ttrace identifier is present
  • Optional size-based and time-based file rotation with retention and gzip compression
  • Optional forwarding of error-level log entries to Sentry

Installation

go get github.com/choveylee/tlog

Example

package main

import (
	"context"

	"github.com/choveylee/tlog"
)

func handleRequest(ctx context.Context, requestID string, userID int, err error) {
	tlog.I(ctx).Msg("service startup completed successfully")
	tlog.I(ctx).Detailf("user_id=%d", userID).Msgf("request %s has been accepted for processing", requestID)

	if err != nil {
		tlog.E(ctx).Err(err).Msg("request processing failed")
	}
}

Configuration

tlog reads configuration during package initialization through tcfg. Exported constants such as AppName, LogLevel, LogFileEnable, LogFilePath, and SentryDsn define the supported keys. Use tcfg.LocalKey when environment-specific scoping is required.

Common configuration keys include the following:

  • AppName
  • LogLevel
  • LogFileEnable
  • LogFilePath
  • LogFileSize
  • LogFileRotate
  • LogFileExpired
  • LogFileCount
  • LogFileCompress
  • SentryDsn

Documentation

See doc.go for the package overview and rendered API references. To inspect the package locally, run:

go doc -all github.com/choveylee/tlog

About

log system support sentry & file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages