diff options
author | ShadowNinja <shadowninja@minetest.net> | 2015-10-13 03:57:44 -0400 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2015-10-14 01:03:54 -0400 |
commit | 2139d7d45fb1a8ed250ad96c9975c581f02f72a9 (patch) | |
tree | 3e954063710add83723798937637db7c67a254eb /builtin/common | |
parent | e0b57c1140554fccbf3e57a036cc4100887ab8f1 (diff) | |
download | minetest-2139d7d45fb1a8ed250ad96c9975c581f02f72a9.tar.gz minetest-2139d7d45fb1a8ed250ad96c9975c581f02f72a9.tar.bz2 minetest-2139d7d45fb1a8ed250ad96c9975c581f02f72a9.zip |
Refactor logging
- Add warning log level
- Change debug_log_level setting to enumeration string
- Map Irrlicht log events to MT log events
- Encapsulate log_* functions and global variables into a class, Logger
- Unify dstream with standard logging mechanism
- Unify core.debug() with standard core.log() script API
Diffstat (limited to 'builtin/common')
-rw-r--r-- | builtin/common/strict.lua | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/builtin/common/strict.lua b/builtin/common/strict.lua index c7b86461f..05ceadf7a 100644 --- a/builtin/common/strict.lua +++ b/builtin/common/strict.lua @@ -9,11 +9,6 @@ function core.global_exists(name) end -local function warn(message) - print(os.date("%H:%M:%S: WARNING: ")..message) -end - - local meta = {} local declared = {} -- Key is source file, line, and variable name; seperated by NULs @@ -27,7 +22,7 @@ function meta:__newindex(name, value) info.currentline, name) if not warned[warn_key] and info.what ~= "main" and info.what ~= "C" then - warn(("Assignment to undeclared ".. + core.log("warning", ("Assignment to undeclared ".. "global %q inside a function at %s.") :format(name, desc)) warned[warn_key] = true @@ -35,9 +30,8 @@ function meta:__newindex(name, value) declared[name] = true end -- Ignore mod namespaces - if WARN_INIT and (not core.get_current_modname or - name ~= core.get_current_modname()) then - warn(("Global variable %q created at %s.") + if WARN_INIT and name ~= core.get_current_modname() then + core.log("warning", ("Global variable %q created at %s.") :format(name, desc)) end rawset(self, name, value) @@ -48,7 +42,7 @@ function meta:__index(name) local info = debug.getinfo(2, "Sl") local warn_key = ("%s\0%d\0%s"):format(info.source, info.currentline, name) if not declared[name] and not warned[warn_key] and info.what ~= "C" then - warn(("Undeclared global variable %q accessed at %s:%s") + core.log("warning", ("Undeclared global variable %q accessed at %s:%s") :format(name, info.short_src, info.currentline)) warned[warn_key] = true end |