ADD: module documentation
This commit is contained in:
parent
d57f1e182e
commit
08b0e407bb
@ -1,21 +1,37 @@
|
||||
package OSSEC::Log;
|
||||
|
||||
# ABSTRACT: OSSEC::Log - Module for logging OSSEC log messages
|
||||
# ABSTRACT: Module/class for simplifying logging of OSSEC log messages
|
||||
use strict;
|
||||
use warnings;
|
||||
use Moose;
|
||||
use DateTime;
|
||||
use File::Basename;
|
||||
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This Module/Class is part of the OSSEC distribution.
|
||||
It simplifies logging to files, e.g. for active response. You are able
|
||||
to use different logging types (info,error,fatal,debug) and select the file to log
|
||||
to. See the methods below.
|
||||
|
||||
=cut
|
||||
|
||||
=attr ossecPath
|
||||
|
||||
base path to the ossec installation B<default> /var/ossec
|
||||
base path to the ossec installation B<default> /var/ossec
|
||||
|
||||
Type: String
|
||||
|
||||
=cut
|
||||
has 'ossecPath' => (is => 'rw', isa => 'Str' , default => "/var/ossec" );
|
||||
|
||||
=attr file
|
||||
|
||||
in which file to log the messages
|
||||
In which file to log the messages. The file should be given as the path relative to the
|
||||
OSSEC configuration file.
|
||||
|
||||
Type: String
|
||||
|
||||
=cut
|
||||
has 'file' => (is => 'rw', isa => 'Str');
|
||||
@ -33,7 +49,7 @@ log error message
|
||||
|
||||
=back
|
||||
|
||||
log->error("OSSEC-Jabber","alert not found");
|
||||
log->error("OSSEC-Jabber","alert not found");
|
||||
|
||||
=cut
|
||||
sub error
|
||||
@ -57,7 +73,7 @@ log fatal message and die
|
||||
|
||||
=back
|
||||
|
||||
log->fatal("OSSEC-Jabber","could not connect to mysql server");
|
||||
log->fatal("OSSEC-Jabber","could not connect to mysql server");
|
||||
|
||||
=cut
|
||||
sub fatal
|
||||
@ -82,7 +98,7 @@ log info message
|
||||
|
||||
=back
|
||||
|
||||
log->info("OSSEC-Jabber","alert send");
|
||||
log->info("OSSEC-Jabber","alert send");
|
||||
|
||||
=cut
|
||||
sub info
|
||||
@ -106,7 +122,7 @@ log debug message
|
||||
|
||||
=back
|
||||
|
||||
log->error("OSSEC-Jabber","found alert in database");
|
||||
log->error("OSSEC-Jabber","found alert in database");
|
||||
|
||||
=cut
|
||||
sub debug
|
||||
@ -146,13 +162,9 @@ sub log
|
||||
|
||||
# create the full path to the file
|
||||
my $file = $self->ossecPath() . "/" . $self->file();
|
||||
my $dir = dirname($file);
|
||||
|
||||
# open the logfile
|
||||
open(my $fh1, ">>", "/tmp/log");
|
||||
|
||||
print $fh1 $file . "\n";
|
||||
|
||||
close $fh1;
|
||||
readpipe("mkdir -p $dir");
|
||||
|
||||
my $dt = DateTime->now;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user