diff options
| author | 2016-01-21 16:46:34 -0700 | |
|---|---|---|
| committer | 2016-01-21 16:46:34 -0700 | |
| commit | a73ccb8276861dab3fcba34c2783122655947844 (patch) | |
| tree | 1823287054c36c65de0f43963a180788d082570c /lib/ASM/Log.pm | |
| parent | 939891b050a6c0c5f44acf6ef43a30ee76719a16 (diff) | |
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
Diffstat (limited to 'lib/ASM/Log.pm')
| -rw-r--r-- | lib/ASM/Log.pm | 7 |
1 files changed, 6 insertions, 1 deletions
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 |
