Log::Message::Structured - Simple structured log messages
package MyLogEvent; use Moose; use namespace::autoclean; # Note: you MUST implement a 'stringify' method, or compose a role # that gives you a stringify method. with qw/ Log::Message::Structured for transmission over the network.
The basic Log::Message::Structured role provides the following read only attributes:
The host name of the host the event was generated on. Defaults to the hostname as returned by Sys::Hostname.
The date and time on which the event occurred, as an no of seconds since Jan 1st 1970 (i.e. the output of time())
The date and time on which the event occured, as an ISO8601 date time string (from MooseX::Types::ISO8601). Defaults to the time the object is constructed.
The only non-accessor methods provided are those composed from MooseX::Storage related to serialization and deserialization.
Return the instance as a JSON string.
Inflate an instance of the class from a JSON string.
Return the instance data as a plain data structure (hashref).
Inflate an instance from a plain data structure (hashref).
An empty build method (which will be silently discarded if you have one in your class) is provided, and is wrapped to make sure all attributes are inflated at construction time.
You must implement a stringify method, or compose a stringification role for all Log::Message::Structured events. This is so that events will always be meaningfully loggable be printing them to STDOUT or STDERR, or logging them in a traditional way in a file.
namespace::autoclean does not work correctly with roles that supply overloading. Therefore you should instead use:
use namespace::clean -except => 'meta';
instead in all classes using Log::Message::Structured.
Tomas Doran (t0m)
<bobtfish@bobtfish.net>.
Licensed under the same terms as perl itself.