From a73ccb8276861dab3fcba34c2783122655947844 Mon Sep 17 00:00:00 2001 From: William Heimbigner Date: Thu, 21 Jan 2016 16:46:34 -0700 Subject: Have the Inspect/opalert routines print a backlog to an incident-specific logfile, rather than a single file, and include a shortlink to this logfile when generating alerts --- lib/ASM/Log.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/ASM/Log.pm') diff --git a/lib/ASM/Log.pm b/lib/ASM/Log.pm index a362b53..ef204f0 100644 --- a/lib/ASM/Log.pm +++ b/lib/ASM/Log.pm @@ -6,6 +6,8 @@ use strict; use ASM::Util; use POSIX qw(strftime); +use Data::UUID; + no if $] >= 5.017011, warnings => 'experimental::smartmatch'; sub new @@ -16,6 +18,7 @@ sub new $self->{CONFIG} = $::settings->{log}; $self->{backlog} = {}; $self->{CONN} = $conn; + $self->{UUID} = Data::UUID->new; bless($self); mkdir($self->{CONFIG}->{dir}); $conn->add_handler('public', sub { logg($self, @_); }, "before"); @@ -36,13 +39,15 @@ sub incident my $self = shift; my ($chan, $header) = @_; $chan = lc $chan; - open(FH, '>>', 'dctlog.txt'); + my $uuid = $self->{UUID}->create_str(); + open(FH, '>', $self->{CONFIG}->{detectdir} . $uuid . '.txt'); print FH $header; if (defined($self->{backlog}->{$chan})) { print FH join('', @{$self->{backlog}->{$chan}}); } print FH "\n\n"; close(FH); + return $uuid; } #writes out the backlog to a file which correlates to ASM's SQL actionlog table -- cgit v1.2.3