Skip to content

Commit 01da050

Browse files
author
lajandy
committed
* heliosx_logger_hires_search: more polish, deactivated debugging
messages by default. * Makefile.PL: added parent as a prereq because it was left off earlier. * Updated and filled in a lot of missing documentation in README, README.md, HiRes.pm, and heliosx_logger_hires_search. * "Renamed HeliosX-Logger-HiRes.t" to "1.t".
1 parent fe219eb commit 01da050

File tree

7 files changed

+116
-30
lines changed

7 files changed

+116
-30
lines changed

MANIFEST

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ README
99
sql/heliosx_logger_hires_mysql.sql
1010
sql/heliosx_logger_hires_oracle.sql
1111
sql/heliosx_logger_hires_sqlite.sql
12-
t/HeliosX-Logger-HiRes.t
12+
t/1.t

Makefile.PL

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ my %eumm_params = (
1111
'Helios' => 2.80,
1212
'Time::HiRes' => 1.86,
1313
'Time::Piece' => 1.12,
14+
'parent' => 0.221,
1415
},
1516
EXE_FILES => ['heliosx_logger_hires_search'],
1617
INST_SCRIPT => 'bin',

README

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
HeliosX-Logger-HiRes version 0.10
22
=================================
33

4-
HeliosX::Logger::HiRes is a Helios::Logger logging class that provides logging
5-
with high-resolution timestamp precision with a more normalized database
6-
structure.
4+
HeliosX::Logger::HiRes is a Helios::Logger logging class that provides
5+
logging with high-resolution timestamp precision with a more
6+
normalized database structure.
77

88
INSTALLATION
99

@@ -14,12 +14,20 @@ To install this module type the following:
1414
make test
1515
make install
1616

17+
This module requires schema modifications to your Helios collective
18+
database. Data description language (DDL) describing these
19+
modifications are detailed in files in the sql/ directory. Find the
20+
.sql file appropriate to your RDBMS and modify it as necessary for
21+
your environment, and run the SQL to create the database structures.
22+
1723
DEPENDENCIES
1824

1925
This module requires these other modules and libraries:
2026

2127
Helios 2.8x
28+
Time::HiRes 1.86
2229
Time::Piece 1.12
30+
parent 0.221
2331

2432
COPYRIGHT AND LICENSE
2533

README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
11
HeliosX-Logger-HiRes version 0.10
22
=================================
3-
43
HeliosX::Logger::HiRes is a Helios::Logger logging class that provides logging
54
with high-resolution timestamp precision with a more normalized database
65
structure.
76

87
INSTALLATION
9-
8+
------------
109
To install this module type the following:
1110

12-
perl Makefile.PL
13-
make
14-
make test
15-
make install
11+
perl Makefile.PL
12+
make
13+
make test
14+
make install
1615

17-
DEPENDENCIES
16+
This module requires schema modifications to your Helios collective database.
17+
Data description language (DDL) describing these modifications are detailed in
18+
files in the `sql/` directory. Find the `.sql` file appropriate to your RDBMS
19+
and modify it as necessary for your environment, and run the SQL to create the
20+
database structures.
1821

22+
DEPENDENCIES
23+
------------
1924
This module requires these other modules and libraries:
2025

21-
Helios 2.8x
22-
Time::Piece 1.12
26+
* Helios 2.80 or later
27+
* Time::HiRes 1.86 or later
28+
* Time::Piece 1.12 or later
29+
* parent 0.221 or later
2330

2431
COPYRIGHT AND LICENSE
25-
32+
---------------------
2633
Copyright (C) 2015 by Logical Helion, LLC.
2734

2835
This library is free software; you can redistribute it and/or
2936
modify it under the terms of the Artistic License 2.0. See the
3037
included LICENSE file for details.
3138

3239
This software comes with no warranty of any kind.
33-

heliosx_logger_hires_search

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use warnings;
66
use Getopt::Long;
77
use Time::Local;
88
use Time::Piece;
9-
use Data::Dumper; #[]
109

1110
use Helios::ObjectDriver;
1211
use Helios::LogEntry::Levels ':all';
@@ -33,25 +32,28 @@ our ($OPT_START_DATE, $OPT_END_DATE, $OPT_HOSTNAME, $OPT_PID, $OPT_JOBID,
3332
$OPT_SORT, $OPT_TAIL, $OPT_FOLLOW);
3433
our ($OPT_HELP, $OPT_VERSION, $OPT_DEBUG);
3534

36-
our $DEBUG_MODE = 1;
35+
our $DEBUG_MODE = 0;
3736
our $FOLLOW_MODE = 0;
3837
our $TAIL_MODE = 0;
3938
our $LAST_LOGID = 0;
4039

4140
GetOptions(
4241
"start-date=s" => \$OPT_START_DATE,
4342
"end-date=s" => \$OPT_END_DATE,
43+
4444
"hostname=s" => \$OPT_HOSTNAME,
4545
"pid=i" => \$OPT_PID,
4646
"jobid=s" => \$OPT_JOBID,
4747
"jobtype=s" => \$OPT_JOBTYPE,
4848
"service=s" => \$OPT_SERVICE,
4949
"message=s" => \$OPT_MESSAGE,
5050
"priority=s" => \$OPT_PRIORITY,
51+
5152
"n|lines|limit=i" => \$OPT_LIMIT,
5253
"sort=s" => \$OPT_SORT,
5354
"tail" => \$OPT_TAIL,
5455
"follow" => \$OPT_FOLLOW,
56+
5557
"help" => \$OPT_HELP,
5658
"version" => \$OPT_VERSION,
5759
"debug" => \$OPT_DEBUG,
@@ -174,7 +176,10 @@ if ($FOLLOW_MODE) {
174176

175177
#[] t
176178
if ($DEBUG_MODE) {
177-
print Dumper(\%search_opts);
179+
print "SEARCH OPTIONS:\n";
180+
foreach my $opt (sort keys %search_opts) {
181+
print $opt,' => ',$search_opts{opt},"\n";
182+
}
178183
}
179184

180185

@@ -190,13 +195,13 @@ eval {
190195
}
191196

192197
foreach ( @logs ) {
193-
# print Dumper($_);
194198
my $tp = localtime $_->log_time;
195199
my ($sec, $fract) = split(/\./, $_->log_time);
196200
my $date = $tp->ymd.' '.$tp->hms.'.'.$fract;
197201
my $jobinfo = $_->jobid ? ' [Jobid '.$_->jobid.']' : '';
198202
$LAST_LOGID = $_->logid;
199-
print $_->logid,' [',$date,'] ',$_->host,' ',$_->service,'[',$_->pid,']: ',$LOG_PRIORITIES[$_->priority],$jobinfo,' ',$_->message,"\n";
203+
print $_->logid.' ' if $DEBUG_MODE; #[]t
204+
print '[',$date,'] ',$_->host,' ',$_->service,'[',$_->pid,']: ',$LOG_PRIORITIES[$_->priority],$jobinfo,' ',$_->message,"\n";
200205
}
201206

202207
1;
@@ -215,13 +220,13 @@ if ($FOLLOW_MODE) {
215220
{ sort => 'log_time', direction => 'ascend' }
216221
);
217222
foreach ( @logs ) {
218-
# print Dumper($_);
219223
my $tp = localtime $_->log_time;
220224
my ($sec, $fract) = split(/\./, $_->log_time);
221225
my $date = $tp->ymd.' '.$tp->hms.'.'.$fract;
222226
my $jobinfo = $_->jobid ? ' [Jobid '.$_->jobid.']' : '';
223227
$LAST_LOGID = $_->logid;
224-
print $_->logid,' [',$date,'] ',$_->host,' ',$_->service,'[',$_->pid,']: ',$LOG_PRIORITIES[$_->priority],$jobinfo,' ',$_->message,"\n";
228+
print $_->logid.' ' if $DEBUG_MODE; #[]t
229+
print '[',$date,'] ',$_->host,' ',$_->service,'[',$_->pid,']: ',$LOG_PRIORITIES[$_->priority],$jobinfo,' ',$_->message,"\n";
225230
}
226231
1;
227232
} or do {
@@ -268,20 +273,20 @@ heliosx_logger_hires_search - search the Helios high resolution log
268273
269274
The heliosx_logger_hires_search command can be used to display log messages
270275
matching specified criteria in the enhanced Helios log provided by
271-
HeliosX::Logger::HiRes. It provides a much more convenient way of accessing
276+
L<HeliosX::Logger::HiRes>. It provides a much more convenient way of accessing
272277
log messages than using SQL queries from a database client like SQL*Plus or
273278
sqlite3.
274279
275280
=head1 RUN OPTIONS
276281
277-
=head2 start-date="YYYY-MM-DDTHH24:MI:SS"
282+
=head2 --start-date="YYYY-MM-DDTHH24:MI:SS"
278283
279-
=head2 end-date="YYYY-MM-DDTHH24:MI:SS"
284+
=head2 --end-date="YYYY-MM-DDTHH24:MI:SS"
280285
281286
Specify a date range of log messages to display. Dates should be in ISO8601
282287
format. If only --start-date is specified, log messages will be displayed from
283288
that date forward until there are no more log messages. If only --end-date is
284-
specified, log messages will be displayed from the the earliest through the
289+
specified, log messages will be displayed from the earliest through the
285290
end date specified.
286291
287292
Normally, heliosx_logger_hires_search displays a maximum number of log

lib/HeliosX/Logger/HiRes.pm

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use Helios::LogEntry::Levels ':all';
1212
use Helios::Error::LoggingError;
1313
use HeliosX::Logger::HiRes::LogEntry;
1414

15-
our $VERSION = '0.10_0000';
15+
our $VERSION = '0.10_0001';
1616

1717
=head1 NAME
1818
@@ -44,8 +44,58 @@ view and search for log messages at the command line.
4444
4545
=head1 CONFIGURATION
4646
47-
#[] missing
47+
HeliosX::Logger::HiRes must be added to your service using the B<loggers>
48+
directive either using the B<helios_config_set> command or in B<helios.ini>.
4849
50+
Additionally, as HeliosX::Logger::HiRes is largely intended to replace the
51+
Helios internal logger, once you are sure it is working properly in your
52+
installation you should turn off the Helios default logger using the
53+
B<internal_logger=off> option.
54+
55+
See the L<Helios::Configuration> page for complete information about the
56+
B<loggers> and B<internal_logger> directives.
57+
58+
HeliosX::Logger::HiRes itself can be configured using the options below:
59+
60+
=over 4
61+
62+
=item * log_priority_threshold
63+
64+
Unlike L<HeliosX::Logger::Syslog> and L<HeliosX::Logger::Log4perl>,
65+
HeliosX::Logger::HiRes supports the Helios internal logger's
66+
B<log_priority_threshold> option to limit the messages actually being logged
67+
to a certain level. Unlike the others, HeliosX::Logger::HiRes is intended to
68+
replace rather than augment the Helios internal logger, so most users running
69+
HeliosX::Logger::HiRes will most likely turn off the Helios internal
70+
logger. Rather than create confusion with a separate threshold option,
71+
HeliosX::Logger::HiRes honors the internal logger's built-in
72+
B<log_priority_threshold> option.
73+
74+
The B<log_priority_threshold> value should be an integer matching one of the
75+
Helios logging priorities in L<Helios::LogEntry::Levels>:
76+
77+
Priority Name Integer Value
78+
LOG_EMERG 0
79+
LOG_ALERT 1
80+
LOG_CRIT 2
81+
LOG_ERR 3
82+
LOG_WARNING 4
83+
LOG_NOTICE 5
84+
LOG_INFO 6
85+
LOG_DEBUG 7
86+
87+
Examples:
88+
89+
# in helios.ini
90+
# for all services on this host, log everything but debug messages
91+
[global]
92+
log_priority_threshold=6
93+
94+
# at the command line, set all instances of MyService
95+
# to only log warnings and worse
96+
helios_config_set -s MyService -H="*" -p log_priority_threshold -v 4
97+
98+
=back
4999
50100
=head1 IMPLEMENTED METHODS
51101
@@ -59,18 +109,34 @@ sub init { }
59109

60110
=head2 logMsg($job, $priority, $message)
61111
62-
#[] description
112+
The logMsg() method takes a job, priority, and log message and savesthe message
113+
to the high-resolution log table in the Helios collective database.
114+
115+
The job parameter should be a Helios::Job object. If the job value is
116+
undefined, no jobid is saved with the message.
117+
118+
If the priority parameter is undefined, logMsg() defaults the message's
119+
priority to 6 (LOG_INFO).
63120
64121
=cut
65122

66123
sub logMsg {
67124
my $self = shift;
125+
unless (scalar @_ == 3) { Helios::Error::LoggingError->throw(__PACKAGE__."->logMsg() ERROR: logMsg() requires 3 arguments: \$job, \$priority, \$message."); }
68126
my ($job, $priority, $message) = @_;
69127

128+
# deal with the log priority & threshold (if set)
129+
$priority = defined($priority) ? $priority : LOG_INFO;
130+
my $threshold = defined($self->getConfig()->{log_priority_threshold}) ? $self->getConfig()->{log_priority_threshold} : LOG_DEBUG;
131+
if ($priority > $threshold) {
132+
return 1;
133+
}
134+
70135
my $success = 0;
71136
my $retries = 0;
72137
my $err;
73138

139+
# deal with jobid & jobtypeid
74140
my $jobid = defined($job) ? $job->getJobid() : undef;
75141
my $jobtypeid = defined($job) ? $job->getJobtypeid() : undef;
76142

@@ -85,7 +151,7 @@ sub logMsg {
85151
jobid => $jobid,
86152
jobtypeid => $jobtypeid,
87153
service => $self->getService(),
88-
priority => defined($priority) ? $priority : LOG_INFO,
154+
priority => $priority,
89155
message => $message,
90156
);
91157
$drvr->insert($obj);
File renamed without changes.

0 commit comments

Comments
 (0)