From d2fbf3c11fb10c2b76455df2a718a8c8d88bf16d Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 5 Jan 2023 16:14:52 +0100 Subject: utils: add logging functions --- utils.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'utils.lua') diff --git a/utils.lua b/utils.lua index eb698dc..0a8d54f 100644 --- a/utils.lua +++ b/utils.lua @@ -146,4 +146,20 @@ function M.notify_singleton(wsp, id, args) wsp.notify_tbl[id] = naughty.notify(args) end +function M.log(component, msg, ...) + local prefix = string.format('[awesome/%s] ', component) + local str = string.format(msg, ...) + + print(prefix .. str) + + return prefix, str +end + +function M.warn(component, msg, ...) + local prefix, str = M.log(component, msg, ...) + naughty.notify({ preset = naughty.config.presets.critical, + title = prefix, + text = str }) +end + return M -- cgit v1.2.3