local skynet = require "skynet" local skynet_error = skynet.error local string_format = string.format local table_insert = table.insert local os_date = os.date local os_time = os.time local const_header = { "(T)|", "(D)|", "(I)|", "(W)|", "(E)|", "(F)|", "(TS)" } local header = const_header local function print(level, fmt, ...) skynet_error( os_date("[%m/%d %X]", os_time()), header[level], string_format(fmt, ...)) end local logger = {} function logger.label(name) if name then header = {} for _, v in ipairs(const_header) do table_insert(header, v..name) end else header = const_header end end function logger.test(fmt, ...) print(7, fmt, ...) end -- function logger.test(fmt, ...) end function logger.trace(fmt, ...) print(1, fmt, ...) end function logger.debug(fmt, ...) print(2, fmt, ...) end function logger.info(fmt, ...) print(3, fmt, ...) end function logger.warn(fmt, ...) print(4, fmt, ...) end function logger.error(fmt, ...) print(5, fmt, ...) end function logger.fatal(fmt, ...) print(6, fmt, ...) end return logger