Use a more standard date format

This commit is contained in:
Alfredo Cardigliano 2021-02-25 15:27:28 +01:00
parent de67f9b13f
commit b6c083c8bb

View file

@ -108,8 +108,6 @@ function syslog.sendMessage(settings, notif, severity)
local facility = 14 -- log alert
local level = 1 -- alert (what about mapping severity?)
local prio = (facility * 8) + level
local date = format_utils.formatEpoch() -- "2020-11-09 18:00:00"
local iso_time = format_utils.formatEpochISO8601() -- ""
local host_info = ntop.getHostInformation()
local host = host_info.ip
local tag = "ntopng"
@ -117,17 +115,22 @@ function syslog.sendMessage(settings, notif, severity)
local pid = info.pid
if syslog_format and syslog_format == "plaintextrfc" then
local iso_time = format_utils.formatEpochISO8601() -- "2020-11-19T18:31:21.003Z"
-- RFC5424 Format:
-- <PRIO>VERSION ISOTIMESTAMP HOSTNAME APPLICATION PID MESSAGEID MSG
-- Example:
-- <113>1 2020-11-19T18:31:21.003Z 192.168.1.1 ntopng 21365 ID1 -
msg = "<"..prio..">1 "..iso_time.." "..host.." "..tag.." "..pid.." - - "..msg
else
-- local log_time = format_utils.formatEpoch() -- "2020-11-09 18:00:00"
local log_time = os.date("!%b %d %X") -- "Feb 25 09:58:12"
-- Unix Format:
-- <PRIO>DATE TIME DEVICE APPLICATION[PID]: MSG
-- Example:
-- <113>09/11/2020 18:31:21 192.168.1.1 ntopng[21365]: ...
msg = "<"..prio..">"..date.." "..host.." "..tag.."["..pid.."]: "..msg
msg = "<"..prio..">"..log_time.." "..host.." "..tag.."["..pid.."]: "..msg
end
if settings.protocol == 'tcp' then