Commit 7ce10069 authored by Andrei Mihu's avatar Andrei Mihu
Browse files

New Lua runtime function to print a log message at debug level.

parent 103beb4a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
- Add group ID to content of in-app notifications relating to groups.
- New runtime function to get a single match by ID.
- New runtime functions for link operations.
- New Lua runtime function to print a log message at debug level.

### Changed
- Replace metrics implementation.
+12 −0
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ func (n *RuntimeLuaNakamaModule) Loader(l *lua.LState) int {
		"authenticate_google":                n.authenticateGoogle,
		"authenticate_steam":                 n.authenticateSteam,
		"authenticate_token_generate":        n.authenticateTokenGenerate,
		"logger_debug":                       n.loggerDebug,
		"logger_info":                        n.loggerInfo,
		"logger_warn":                        n.loggerWarn,
		"logger_error":                       n.loggerError,
@@ -1647,6 +1648,17 @@ func (n *RuntimeLuaNakamaModule) getLuaModule(l *lua.LState) string {
	return strings.TrimPrefix(src[:len(src)-1], n.config.GetRuntime().Path)
}

func (n *RuntimeLuaNakamaModule) loggerDebug(l *lua.LState) int {
	message := l.CheckString(1)
	if message == "" {
		l.ArgError(1, "expects message string")
		return 0
	}
	n.logger.Debug(message, zap.String("runtime", "lua"))
	l.Push(lua.LString(message))
	return 1
}

func (n *RuntimeLuaNakamaModule) loggerInfo(l *lua.LState) int {
	message := l.CheckString(1)
	if message == "" {