#!/usr/bin/lua -- Created by jiaqiang.ye@lnxall.com -- Simple Wrapper for ubuslog/core.so -- 2023/02/18 local ubuslog = require "ubuslog.core" local _M = {} _M.LOG_DEBUG = ubuslog.LOG_DEBUG _M.LOG_INFO = ubuslog.LOG_INFO _M.LOG_NOTICE = ubuslog.LOG_NOTICE _M.LOG_WARNING = ubuslog.LOG_WARNING _M.LOG_ERR = ubuslog.LOG_ERR _M.LOG_CRIT = ubuslog.LOG_CRIT _M.LOG_ALERT = ubuslog.LOG_ALERT _M.LOG_EMERG = ubuslog.LOG_EMERG _M.loglevel_get = ubuslog.loglevel_get _M.loglevel_set = ubuslog.loglevel_set _M.raw_log = ubuslog.log _M.reinit = ubuslog.log_reinit _M.log = function (loglevel, ...) local typn = type(loglevel) if typn ~= "number" then io.stderr:write(string.format("Error, invalid type of loglevel: %s\n", typn)) io.stderr:flush() return false end local argc = 0 local args = {} loglevel = math.floor(loglevel) for _, argv in ipairs{...} do typn = type(argv) if typn ~= "string" then argv = tostring(argv) typn = type(argv) end if typn == "string" then argc = argc + 1 args[argc] = argv end end if argc == 0 then io.stderr:write("Error, no string argument given to ubuslog.log(...)\n") io.stderr:flush() return false end return _M.raw_log(loglevel, unpack(args)) end return _M