package log import ( _ "embed" "apigo.cc/gojs" "apigo.cc/gojs/goja" ) //go:embed log.ts var logTS string //go:embed README.md var logMD string func init() { obj := map[string]any{ "info": func(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value { args := gojs.MakeArgs(&argsIn, vm).Check(1) args.Logger.Info(args.Str(0), args.Map2Array(1)...) return nil }, "warn": func(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value { args := gojs.MakeArgs(&argsIn, vm).Check(1) args.Logger.Warning(args.Str(0), args.Map2Array(1)...) return nil }, "error": func(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value { args := gojs.MakeArgs(&argsIn, vm).Check(1) args.Logger.Error(args.Str(0), args.Map2Array(1)...) return nil }, "debug": func(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value { args := gojs.MakeArgs(&argsIn, vm).Check(1) args.Logger.Debug(args.Str(0), args.Map2Array(1)...) return nil }, } gojs.Register("apigo.cc/gojs/log", gojs.Module{ Object: obj, Desc: "logger api by github.com/ssgo/log", TsCode: logTS, Example: logMD, }) }