File: logger.lua

package info (click to toggle)
lua-systemd 0~git20160517-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 412 kB
  • ctags: 626
  • sloc: ansic: 4,022; makefile: 3
file content (15 lines) | stat: -rw-r--r-- 382 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
local journal = require "systemd.journal"

function log(severity, msg, level)
	local info = debug.getinfo((level or 1)+1, "nlS")
	if info.currentline == -1 then
		info.currentline = nil
	end
	return assert(journal.sendt{
		CODE_FILE = info.short_src;
		CODE_FUNC = info.name;
		CODE_LINE = info.currentline;
		PRIORITY = journal.LOG[severity:upper()] or 5;
		MESSAGE = msg;
	})
end