forked from tarantool/luatest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.lua
36 lines (27 loc) · 767 Bytes
/
log.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local tarantool_log = require('log')
local utils = require('luatest.utils')
-- Utils for logging
local log = {}
local default_level = 'info'
local function _log(level, msg, ...)
if utils.version_current_ge_than(2, 5, 1) then
return tarantool_log[level](msg, ...)
end
end
--- Extra wrapper for `__call` function
-- An additional function that takes `table` as
-- the first argument to call table function.
local function _log_default(t, msg, ...)
return t[default_level](msg, ...)
end
function log.info(msg, ...)
return _log('info', msg, ...)
end
function log.warn(msg, ...)
return _log('warn', msg, ...)
end
function log.error(msg, ...)
return _log('error', msg, ...)
end
setmetatable(log, {__call = _log_default})
return log