Logging library for Temporal Go SDK

I’ve added a KVLogger interface to my logging adapter package, Logur: https://github.com/logur/logur

You can use its adapters (https://github.com/logur?q=adapter-&type=&language=) to use a wide number of known loggers in Temporal.

For example, using it with Logrus:

package main

import (
	"github.com/sirupsen/logrus"
	logrusadapter "logur.dev/adapter/logrus"
	"logur.dev/logur"
)

func main() {
	// feed this logger into Temporal
	logger := logur.LoggerToKV(logrusadapter.New(logrus.New()))
}

Keep in mind, that in terms of performance it might have a slight penalty. I don’t think it’s noticeable in most of the cases, but under the hood the implementation converts the log context to a map, then based on the original logger library, it might be converted back to a slice.

I’m going to provide more “native” adapters for each logger library, implementing the KVLogger interface, but you can quickly get started with this implementation if you don’t want to write your own adapter for your favorite logging library.

2 Likes