The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

 Fault::Msg - Internal message encapsulation class.

SYNOPSIS

 use Fault::Msg;
 $self   = Fault::Msg->new     ($m,$t,$p);
 $m      = $self->set_msg      ($m);
 $t      = $self->set_type     ($t);
 $p      = $self->set_priority ($p);
 $prefix = $self->set_prefix   ($prefix);
 $tag    = $self->set_tag      ($tag);

 ($stamp,$p,$t,$process,$taggedmsg) = $self->get;

 $taggedmsg   = $self->msg;
 $stamp       = $self->timestamp;
 $time        = $self->time;
 $date        = $self->date;
 $processname = $self->processname;
 $p           = $self->priority;
 $t           = $self->type;
 $prefix      = $self->prefix;
 $tag         = $self->tag;
 $bool        = $self->is_blank;
 $line        = $self->stamped_log_line;
 $line        = $self->unstamped_log_line;

Inheritance

 UNIVERSAL
  Fault::Msg

Description

A Fault::Msg is an object internal to the Fault::Logger system. It encapsultes all the required information about a message that will be used for a fault or log report. It makes certain that all required values are present and correct so that other internal classes do not have to do so.

The message text itself is stored in three parts: prefix, tag and msg. The prefix is used only in printed log lines. A tag, if present, is included as if it were part of the message text.

Examples

 None.

Class Variables

 None.

Instance Variables

  timestamp    The time and date stamp at the time of creation of Msg.
  date         The date portion of the timestamp string.
  time         The time portion of the timestamp string.
  process      $::PROCESS_NAME or a default value.
  msg          The base message text.
  type         The message type.
  priority     The syslog priority type.
  blankflg     True if the base message is a default.
  prefix       A special prefix text that is not 'part' of the message.
  tag          A prefix that when set is alway included with the base
               message.

Class Methods

$self = Fault::Msg->new ($m,$t,$p)
$self = Fault::Msg->new ($m,$t)
$self = Fault::Msg->new ($m)
$self = Fault::Msg->new

Create an instance of $Fault::Msg for the message, type and priority specified. If values are undef, defaults will be used for the missing values.

If the message ends with a newline, it is removed. If there are embedded format chars the line will be rejected by POSIX::printable.

Instance Methods

$date = $self->date

Return the date string, yyyymmdd.

($stamp,$p,$t,$process,$taggedmsg) = $self->get

Return the basic list of items used in a log message. Taggedmsg does not include the prefix as prefix's are for log printing.

$bool = $self->is_blank

Return true if the base message text is empty and has been replaced by a default.

$taggedmsg = $self->msg

Return a concatenated string consisting of the tag and the base message.

$p = $self->priority

Return the priority.

$prefix = $self->prefix

Return the message prefix.

$processname = $self->processname

Return the messages originating process name.

$m = $self->set_msg ($m)

Set the base message string. An undefined value will set the blank message flag and set the base message to an informative default message.

If the message ends with a newline, it is removed. If there are embedded format chars the line will be rejected by POSIX::printable.

$p = $self->set_priority ($p)

Set the syslog priority string. An undefined $p will set the priority to a default value compatible with the current string type setting. [See Fault::Logger for more information on defaulting.]

$prefix = $self->set_prefix ($prefix)

Set the prefix string. A prefix will appear before a message and tag in the format '[$prefix] '. A prefix will only appear in strings generated via stamped_log_line and unstamped_log_line.

An undefined $prefix will set prefix to the default value: "".

$tag = $self->set_tag ($tag)

Set a message tag. A tag will be prepended to the message when ever it is used. A undefined $tag will set tag to the default value: "".

$t = $self->set_type ($t)

Set the type of the message. An undefined type string will set type to the default value: 'BUG'.

$line = $self->stamped_log_line

Return a line formatted for use in a private log format or printing format:

    "$date $time UTC> $process: $type($priority): ${prefix}${tag}${msg}"
$tag = $self->tag

Return the tag string.

$time = $self->time

Return a time string. A time is formatted: hhmmss.

$stamp = $self->timestamp

Return the message timestamp. A timestamp is formatted: yyyymmddhhmmss.

$t = $self->type

Return the message type string.

$line = $self->unstamped_log_line

Return a line formatted for use in a syslog format:

    "$process: $type($priority): ${prefix}${tag}${msg}"

Private Class Method

 None.

Private Instance Methods

 None.

Errors and Warnings

 None.

KNOWN BUGS

POSIX::isprint is used to filter whether a message is junk or not. It should probably make an effort to sanitize the string of format characters rather than reject a potentially good message.

See TODO.

Errors and Warnings

 None.

SEE ALSO

 None.

AUTHOR

Dale Amon <amon@vnl.com>

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 385:

You forgot a '=back' before '=head1'

Around line 481:

=back doesn't take any parameters, but you said =back 4