summaryrefslogtreecommitdiff
path: root/utils.lua
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-01-05 16:14:52 +0100
committerAnton Khirnov <anton@khirnov.net>2023-01-05 16:14:52 +0100
commitd2fbf3c11fb10c2b76455df2a718a8c8d88bf16d (patch)
treeddac900d5c993625d2d7ecffbb37635f39a64609 /utils.lua
parent8a99126930b902171204fd7e1c5871014ebffa33 (diff)
utils: add logging functions
Diffstat (limited to 'utils.lua')
-rw-r--r--utils.lua16
1 files changed, 16 insertions, 0 deletions
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