12 Apr 2021 00:08:29 UTC
- Distribution: Log-Agent
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (1)
- Testers (166 / 0 / 0)
- KwaliteeBus factor: 1
- License: artistic_2
- Activity24 month
- Download (56.02KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:1 non-PAUSE userMROGASKI Mark Rogaski
Log::Agent::Message - a log message
require Log::Agent::Message; my $msg = Log::Agent::Message->make("string"); $msg->prepend("string"); $msg->append("string"); my $copy = $msg->clone; print "Message is $msg\n"; # overloaded stringification
The Log::Agent::Message class represents an original log message (a string) to which one may prepend or append other strings, but with the special property that prepended strings aggregate themselves in FIFO order, whilst appended strings aggregate themselves in LIFO order, which is counter-intuitive at first sight.
In plain words, this means that the last routine that prepends something to the message will get its prepended string right next to the original string, regardless of what could have been prepended already. The behaviour is symetric for appending.
The following routines are available:
Append suppled string $str to the original string (given at creation time), at the head of all existing appended strings.
Append suppled string $str to the original string (given at creation time), at the tail of all existing appended strings.
Clone the message. This is not a shallow clone, because the list of prepended and appended strings is recreated. However it is not a deep clone, because the items held in those lists are merely copied (this would matter only when other objects with overloaded stringification routines were supplied to prepend() and append(), which is not the case today in the basic Log::Agent framework).
This is the creation routine.
Prepend supplied string $str to the original string (given at creation time), at the tail of all existing prepended strings.
Prepend supplied string $str to the original string (given at creation time), at the head of all existing prepended strings.
This is the overloaded "" operator, which returns the complete string composed of all the prepended strings, the original string, and all the appended strings.
Raphael Manfredi <Raphael_Manfredi@pobox.com>