/usr/share/perl5/Log/Any/Adapter/Development.pod is in liblog-any-perl 1.038-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | # PODNAME: Log::Any::Adapter::Development
# ABSTRACT: Manual for developing new Log::Any adapters
# vim: ts=4 sts=4 sw=4 et tw=75:
__END__
=pod
=encoding UTF-8
=head1 NAME
Log::Any::Adapter::Development - Manual for developing new Log::Any adapters
=head1 VERSION
version 1.038
=head1 SYNOPSIS
The adapter module:
package Log::Any::Adapter::YAL;
use strict;
use warnings;
use Log::Any::Adapter::Util ();
use base qw(Log::Any::Adapter::Base);
# Optionally initialize object, e.g. for delegation
#
sub init {
my ($self) = @_;
$self->{attr} = ...;
}
# Create logging methods: debug, info, etc.
#
foreach my $method ( Log::Any::Adapter::Util::logging_methods() ) {
no strict 'refs';
*$method = sub { ... };
}
# Create detection methods: is_debug, is_info, etc.
#
foreach my $method ( Log::Any::Adapter::Util::detection_methods() ) {
no strict 'refs';
*$method = sub { ... };
}
and the application:
Log::Any->set_adapter('YAL');
=head1 DESCRIPTION
This document describes how to implement a new Log::Any adapter.
The easiest way to start is to look at the source of existing adapters, such as
L<Log::Any::Adapter::Log4perl|Log::Any::Adapter::Log4perl> and
L<Log::Any::Adapter::Dispatch|Log::Any::Adapter::Dispatch>.
=head1 NAME
Log::Any::Adapter::Development - Manual for developing new Log::Any adapters
=head1 VERSION
version 1.038
=head1 NAMING
If you are going to publicly release your adapter, call it
'Log::Any::Adapter::I<something>' so that users can use it with
Log::Any->set_adapter(I<something>);
If it's an internal driver, you can call it whatever you like and use it like
Log::Any->set_adapter('+My::Log::Adapter');
=head1 BASE CLASS
All adapters must directly or indirectly inherit from
L<Log::Any::Adapter::Base>.
=head1 LOG LEVELS
Log::Any supports the following log levels:
=over 4
=item *
trace
=item *
debug
=item *
info
=item *
notice
=item *
warning
=item *
error
=item *
critical
=item *
alert
=item *
emergency
=back
If the logging mechanism used by your adapter supports different levels,
it's your responsibility to map them appropriately when you implement the
logging and detection methods described below. For example, if your
mechanism only supports "debug", "normal" and "fatal" levels, you might map
the levels like this:
=over 4
=item *
debug: trace, debug
=item *
normal: info, notice, warning
=item *
fatal: error, critical, alert, emergency
=back
=head1 METHODS
=head2 Constructor
The constructor (C<new>) is provided by
L<Log::Any::Adapter::Base|Log::Any::Adapter::Base>. It will:
=over 4
=item *
place any adapter arguments into a hash, along with the category
=item *
bless the hash into your subclass
=item *
call L</init> which may be optionally provided by your subclass
=back
At this point, overriding the default constructor is not supported. Hopefully
it will not be needed.
The constructor is called whenever a log object is requested. e.g. If the
application initializes Log::Any like so:
Log::Any->set_adapter('Log::YAL', yal_object => $yal, depth => 3);
and then a class requests a logger like so:
package Foo;
use Log::Any qw($log);
Then C<$log> will be populated with the return value of:
Log::Any::Adapter::Yal->new(yal_object => $yal, depth => 3, category => 'Foo');
This is memoized, so if the same category should be requested again (e.g.
through a separate C<get_logger> call, the same object will be returned.
Therefore, you should try to avoid anything non-deterministic in your L</init>
function.
=head2 Logging methods (required)
The following methods have no default implementation, and MUST be defined by
your subclass:
=over 4
=item *
debug ($msg)
=item *
info ($msg)
=item *
notice ($msg)
=item *
warning ($msg)
=item *
error ($msg)
=item *
critical ($msg)
=item *
alert ($msg)
=item *
emergency ($msg)
=back
These methods must log a message at the specified level.
To help generate these methods programmatically, you can get a list of the
sub names with the
L<Log::Any::Adapter::Util::logging_methods|Log::Any::Adapter::Util/logging_methods>
function.
=head2 Log-level detection methods (required)
The following methods have no default implementation, and MUST be defined by
your subclass:
=over 4
=item *
is_debug ()
=item *
is_info ()
=item *
is_notice ()
=item *
is_warning ()
=item *
is_error ()
=item *
is_critical ()
=item *
is_alert ()
=item *
is_emergency ()
=back
These methods must return a boolean indicating whether the specified level is
active, i.e. whether the adapter is listening for messages of that level.
To help generate these methods programmatically, you can get a list of the
sub names with the
L<Log::Any::Adapter::Util::detection_methods|Log::Any::Adapter::Util/detection_methods>
function.
=head2 Aliases
Aliases (e.g. "err" for "error") are handled by L<Log::Any::Proxy> and will
call the corresponding real name in your adapter class. You do not need to
implement them in your adapter.
=head2 Optional methods
The following methods have no default implementation but MAY be provided by
your subclass:
=over
=item init
This is called after the adapter object is created and blessed into your class.
Perform any necessary validation or initialization here. For example, you
would use C<init> to create a logging object for delegation, or open a file
or socket, etc.
=back
=head2 Support methods
The following L<Log::Any::Adapter::Base> method may be useful for defining
adapters via delegation:
=over
=item delegate_method_to_slot ($slot, $method, $adapter_method)
Handle the specified C<$method> by calling C<$adapter_method> on the object
contained in C<< $self->{$slot} >>.
See L<Log::Any::Adapter::Dispatch> and L<Log::Any::Adapter::Log4perl> for
examples of usage.
=back
The following L<Log::Any::Adapter::Util> functions give you a list of
methods that you need to implement. You can get logging methods, detection
methods or both:
=over 4
=item *
L<Log::Any::Adapter::Util::logging_methods|Log::Any::Adapter::Util/logging_methods>
=item *
L<Log::Any::Adapter::Util::detection_methods|Log::Any::Adapter::Util/detection_methods>
=item *
L<Log::Any::Adapter::Util::logging_and_detection_methods|Log::Any::Adapter::Util/logging_and_detection_methods>
=back
=head1 AUTHORS
=over 4
=item *
Jonathan Swartz <swartz@pobox.com>
=item *
David Golden <dagolden@cpan.org>
=back
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Jonathan Swartz and David Golden.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=head1 AUTHORS
=over 4
=item *
Jonathan Swartz <swartz@pobox.com>
=item *
David Golden <dagolden@cpan.org>
=back
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Jonathan Swartz and David Golden.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|