mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-18 05:47:32 +00:00
31 lines
674 B
Go
31 lines
674 B
Go
|
package actions
|
||
|
|
||
|
import (
|
||
|
"github.com/zitadel/logging"
|
||
|
|
||
|
"github.com/dop251/goja"
|
||
|
"github.com/dop251/goja_nodejs/console"
|
||
|
)
|
||
|
|
||
|
var ServerLog *logrus
|
||
|
|
||
|
type logrus struct{}
|
||
|
|
||
|
func (*logrus) Log(s string) {
|
||
|
logging.WithFields("message", s).Info("log from action")
|
||
|
}
|
||
|
func (*logrus) Warn(s string) {
|
||
|
logging.WithFields("message", s).Info("warn from action")
|
||
|
}
|
||
|
func (*logrus) Error(s string) {
|
||
|
logging.WithFields("message", s).Info("error from action")
|
||
|
}
|
||
|
|
||
|
func WithLogger(logger console.Printer) Option {
|
||
|
return func(c *runConfig) {
|
||
|
c.modules["zitadel/log"] = func(runtime *goja.Runtime, module *goja.Object) {
|
||
|
console.RequireWithPrinter(logger)(runtime, module)
|
||
|
}
|
||
|
}
|
||
|
}
|