ADD: module documentation

This commit is contained in:
Dominik Meyer 2019-12-20 12:31:40 +01:00
parent d57f1e182e
commit 08b0e407bb
No known key found for this signature in database
GPG Key ID: B4C312B600606B64

View File

@ -1,21 +1,37 @@
package OSSEC::Log; 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 strict;
use warnings; use warnings;
use Moose; use Moose;
use DateTime; 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 =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 =cut
has 'ossecPath' => (is => 'rw', isa => 'Str' , default => "/var/ossec" ); has 'ossecPath' => (is => 'rw', isa => 'Str' , default => "/var/ossec" );
=attr file =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 =cut
has 'file' => (is => 'rw', isa => 'Str'); has 'file' => (is => 'rw', isa => 'Str');
@ -33,7 +49,7 @@ log error message
=back =back
log->error("OSSEC-Jabber","alert not found"); log->error("OSSEC-Jabber","alert not found");
=cut =cut
sub error sub error
@ -57,7 +73,7 @@ log fatal message and die
=back =back
log->fatal("OSSEC-Jabber","could not connect to mysql server"); log->fatal("OSSEC-Jabber","could not connect to mysql server");
=cut =cut
sub fatal sub fatal
@ -82,7 +98,7 @@ log info message
=back =back
log->info("OSSEC-Jabber","alert send"); log->info("OSSEC-Jabber","alert send");
=cut =cut
sub info sub info
@ -106,7 +122,7 @@ log debug message
=back =back
log->error("OSSEC-Jabber","found alert in database"); log->error("OSSEC-Jabber","found alert in database");
=cut =cut
sub debug sub debug
@ -146,13 +162,9 @@ sub log
# create the full path to the file # create the full path to the file
my $file = $self->ossecPath() . "/" . $self->file(); my $file = $self->ossecPath() . "/" . $self->file();
my $dir = dirname($file);
# open the logfile readpipe("mkdir -p $dir");
open(my $fh1, ">>", "/tmp/log");
print $fh1 $file . "\n";
close $fh1;
my $dt = DateTime->now; my $dt = DateTime->now;