mirror of
https://github.com/iDvel/rime-ice.git
synced 2026-04-29 16:26:33 +00:00
style: Lua 统一缩进 4 空格
This commit is contained in:
@@ -42,39 +42,51 @@
|
||||
-- puts(INFO,__FILE__(),__LINE__(),__FUNC__() , ...)
|
||||
--
|
||||
-- global variable
|
||||
function __FILE__(n) n=n or 2 return debug.getinfo(n,'S').source end
|
||||
function __LINE__(n) n=n or 2 return debug.getinfo(n, 'l').currentline end
|
||||
function __FUNC__(n) n=n or 2 return debug.getinfo(n, 'n').name end
|
||||
INFO="log"
|
||||
WARN="warn"
|
||||
ERROR="error"
|
||||
DEBUG="trace"
|
||||
CONSOLE="console"
|
||||
function __FILE__(n)
|
||||
n = n or 2
|
||||
return debug.getinfo(n, 'S').source
|
||||
end
|
||||
|
||||
function __LINE__(n)
|
||||
n = n or 2
|
||||
return debug.getinfo(n, 'l').currentline
|
||||
end
|
||||
|
||||
function __FUNC__(n)
|
||||
n = n or 2
|
||||
return debug.getinfo(n, 'n').name
|
||||
end
|
||||
|
||||
INFO = "log"
|
||||
WARN = "warn"
|
||||
ERROR = "error"
|
||||
DEBUG = "trace"
|
||||
CONSOLE = "console"
|
||||
|
||||
|
||||
|
||||
|
||||
local function tran_msg(...)
|
||||
local msg="\t"
|
||||
for i,k in next, {...} do msg = msg .. ": " .. tostring(k) end
|
||||
return msg
|
||||
local msg = "\t"
|
||||
for i, k in next, { ... } do msg = msg .. ": " .. tostring(k) end
|
||||
return msg
|
||||
end
|
||||
local function puts( tag , ...)
|
||||
if type(tag) ~= "string" then return end
|
||||
local function puts(tag, ...)
|
||||
if type(tag) ~= "string" then return end
|
||||
|
||||
if INFO and tag:match("^" .. INFO) then
|
||||
(log and log.info or print)( tag .. tran_msg(...))
|
||||
elseif WARN and tag:match("^" .. WARN) then
|
||||
(log and log.warning or print)(tag .. tran_msg(...))
|
||||
elseif ERROR and tag:match("^" .. ERROR) then
|
||||
(log and log.error or print)(tag .. tran_msg(...))
|
||||
elseif DEBUG and tag:match("^" .. DEBUG) then
|
||||
(log and log.error or print)(tag .. tran_msg(...))
|
||||
elseif CONSOLE and tag:match( "^" .. CONSOLE ) then
|
||||
( print)( tag .. tran_msg(...))
|
||||
else
|
||||
return
|
||||
end
|
||||
if INFO and tag:match("^" .. INFO) then
|
||||
(log and log.info or print)(tag .. tran_msg(...))
|
||||
elseif WARN and tag:match("^" .. WARN) then
|
||||
(log and log.warning or print)(tag .. tran_msg(...))
|
||||
elseif ERROR and tag:match("^" .. ERROR) then
|
||||
(log and log.error or print)(tag .. tran_msg(...))
|
||||
elseif DEBUG and tag:match("^" .. DEBUG) then
|
||||
(log and log.error or print)(tag .. tran_msg(...))
|
||||
elseif CONSOLE and tag:match("^" .. CONSOLE) then
|
||||
(print)(tag .. tran_msg(...))
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
return puts
|
||||
|
||||
Reference in New Issue
Block a user