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

NAME

Log::Dispatch::Atom - Log to an atom feed.

VERSION

This document describes Log::Dispatch::Atom version 0.01

SYNOPSIS

    use Log::Dispatch::Atom;

    my $log = Log::Dispatch::Atom->new(
        name      => 'foo',
        min_level => 'debug',
        file      => 'file.atom'
    );
    $log->log_message( level => 'error', message => 'A problem happened' );
    $log->log_message( level => 'debug', message => 'Got Here' );

DESCRIPTION

This class implements logging backed by an Atom feed so that you can subscribe to the errors produced by your application.

You should not use this object directly, but should manage it via a Log::Dispatch object.

IMPLEMENTATION NOTES

In order to safely write to the log file, the entire file must be locked each time that an entry is logged. This probably makes it unsuitable for high volume log files.

The log file is opened and closed on each call to log_message().

METHODS

new()

Takes a hash of arguments. Returns a new Log::Dispatch::Atom object. The following parameters are used:

name [mandatory]

The name of the logging object.

min_level [mandatory]

The minimum logging level this object will accept. See Log::Dispatch for more information.

max_level [optional]

The maximum logging level this object will accept. See Log::Dispatch for more information. The default is the highest possible level (ie: no maximum).

file [mandatory]

Specifies the location of the file to read/write the feed from.

feed_id [optional]

Specifies the identity of the feed itself. Normally, this should be set to the published URI of the feed.

If not specified, it will be omitted, which is in violation of the Atom specification. For more information, see http://www.atomenabled.org/developers/syndication/#requiredFeedElements.

feed_title [optional]

The title of the feed. This should probably be set to the name of your application.

If not specified, it will be omitted, which is in violation of the Atom specification. For more information, see http://www.atomenabled.org/developers/syndication/#requiredFeedElements.

XXX This should probably just use the name parameter. What do you think? Let me know.

feed_author [optional]

The author details of a feed. This is specified as a hash reference, which must contain one or more of the three keys name, email and uri.

In order to create a valid Atom feed, you must either supply an author in every single entry (log message), or ensure that the feed itself has an author. The latter is probably the easier solution, so I recommend this parameter be supplied.

NB: The feed_* parameters will only be used when a new feed is being created. If you are creating a new object for an existing feed, they will be ignored.

log_message()

Takes a hash of arguments. Has no return value. The following parameters are used.

message [mandatory]

The actual log message.

level [mandatory]

The level of the message. See Log::Dispatch for a full list.

id [optional]

Each entry requires an id in order for the feed as a whole to be a valid Atom document. It's used by readers of Atom documents to determine whether or not an entry has been seen previously.

If not specified, this will default to an URL comprising the current time plus the pid plus the hostname plus a monotonically increasing integer. eg: tag:fred.example.com,2005-12-07:1133946771/20827/2. This should be good enough for a uniqueness test.

author [optional]

You can specify author details for an individual entry if desired. The author parameter is expected to be a hash reference, which must contain one or more of the keys name, email or uri.

SEE ALSO

XML::Atom, the module used for Atom processing.

The spec for the atom syndication format, http://www.atomenabled.org/developers/syndication/.

DEPENDENCIES

XML::Atom version 0.15.

This module uses flock() to the lock the feed file whilst it's writing, so your version of Perl will need support for that.

BUGS AND LIMITATIONS

Please report any bugs or feature requests to bug-xml-atom-log@rt.cpan.org, or through the web interface at http://rt.cpan.org.

AUTHOR

Dominic Mitchell <cpan (at) happygiraffe.net>

LICENCE AND COPYRIGHT

Copyright (c) 2005, Dominic Mitchell <cpan (at) happygiraffe.net>. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.