Skip to content

breuHQ/slog-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

slog-utils: utilities to work with slog

GitHub release (with filter) GitHub go.mod Go version (subdirectory of monorepo) License GitHub contributors

Utilities for slog for

  • calldepth, add caller skip for helper functions e.g. in 3rd party libraries e.g. temporal et el.

calldepth: add caller skip, similar to that provided by

code taken from golang/go#59145 (comment)

🚀 Install

go get go.breu.io/slog-utils

Compatibility: go >= 1.21

  • ⚠️ Work in Progress
  • ⚠️ Use this library carefully, log processing can be very costly (!)

💡 Usage

package main

import (
 "log/slog"

 "go.temporal.io/sdk/client"

 "go.breu.io/slog-utils/calldepth"
)

func main() {
  adapter := calldepth.NewAdapter(
    calldepth.NewLogger(slog.NewStdLogger()),
    calldepth.WithCallDepth(5), // 5 for activities, 6 for workflows.
  )
  opts := client.Options{
    HostPort: "localhost:7233",
    Logger:   adapter.WithGroup("temporal"),
  }

  tclient, err := client.Dial(opts)
}

👤 Contributors

Contributors

📝 License

Copyright © 2023 Breu Inc.

This project is MIT licensed.