Skip to content

Wiladams/LJIT2systemd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

LJIT2systemd

LuaJIT binding to libsystemd

A typical example

local SDJournal = require("SDJournal")
local sysd = require("systemd")
local fun = require("fun")()

-- Feed this routine a table with the names of the fields
-- you are interested in seeing in the final output table
local function selection(fields, aliases)
	return function(entry)
		local res = {}
		for _, k in ipairs(fields) do
			if entry[k] then
				res[k] = entry[k];
			end
		end
		return res;
	end
end

local function  printTable(entry)
	print(entry)
	each(print, entry)
end



local function printJournalFields(selector, flags)
	flags = flags or 0
	local jnl1 = SDJournal();

	if selector then
		each(printTable, map(selector, map(function(entry) return entry:currentValue() end, jnl1:entries())))
	else
		each(printTable, map(function(entry) return entry:currentValue() end, jnl1:entries()))	
	end
end

--printJournalFields(nil, sysd.SD_JOURNAL_CURRENT_USER)
--printJournalFields(nil, sysd.SD_JOURNAL_SYSTEM)

--printJournalFields(selection({"_HOSTNAME", "SYSLOG_FACILITY"}));
printJournalFields(selection({"_EXE", "_CMDLINE"}));

About

LuaJIT binding to libsystemd

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages