AnyEvent
view release on metacpan or search on metacpan
lib/AnyEvent/IO.pm view on Meta::CPAN
Unlike L<AnyEvent>, which model to use is currently decided at module load
time, not at first use. Future releases might change this.
=head2 RATIONALE
While disk I/O often seems "instant" compared to, say, socket I/O, there
are many situations where your program can block for extended time periods
when doing disk I/O. For example, you access a disk on an NFS server and
it is gone - can take ages to respond again, if ever. Or your system is
extremely busy because it creates or restores a backup - reading data from
disk can then take seconds. Or you use Linux, which for so many years has
a close-to-broken VM/IO subsystem that can often induce minutes or more of
delay for disk I/O, even under what I would consider light I/O loads.
Whatever the situation, some programs just can't afford to block for long
times (say, half a second or more), because they need to respond as fast
as possible.
For those cases, you need asynchronous I/O.
lib/AnyEvent/IO.pm view on Meta::CPAN
to atomically replace it.
aio_link "file", "file.bak", sub {
@_
or return AE::log error => "file: $!";
aio_rename "file.new", "file", sub {
@_
or return AE::log error => "file.new: $!";
print "file atomically replaced by file.new, backup file.bak\n";
};
};
=item aio_symlink $oldpath, $newpath, $cb->($success)
Calls C<symlink> on the paths and passes a true value to the callback on
success.
Example: create a symlink "F<slink> containing "random data".
lib/AnyEvent/Log.pm view on Meta::CPAN
AE::log note => "Attempted to create config, but config already exists.";
AE::log info => "File soandso successfully deleted.";
AE::log debug => "the function returned 3";
AE::log trace => "going to call function abc";
Log level overview:
LVL NAME SYSLOG PERL NOTE
1 fatal emerg exit system unusable, aborts program!
2 alert failure in primary system
3 critical crit failure in backup system
4 error err die non-urgent program errors, a bug
5 warn warning possible problem, not necessarily error
6 note notice unusual conditions
7 info normal messages, no action required
8 debug debugging messages for development
9 trace copious tracing output
"Complex" uses (for speed sensitive code, e.g. trace/debug messages):
use AnyEvent::Log;
lib/AnyEvent/Log.pm view on Meta::CPAN
Logging levels in this module range from C<1> (highest priority) to C<9>
(lowest priority). Note that the lowest numerical value is the highest
priority, so when this document says "higher priority" it means "lower
numerical value".
Instead of specifying levels by name you can also specify them by aliases:
LVL NAME SYSLOG PERL NOTE
1 fatal emerg exit system unusable, aborts program!
2 alert failure in primary system
3 critical crit failure in backup system
4 error err die non-urgent program errors, a bug
5 warn warning possible problem, not necessarily error
6 note notice unusual conditions
7 info normal messages, no action required
8 debug debugging messages for development
9 trace copious tracing output
As you can see, some logging levels have multiple aliases - the first one
is the "official" name, the second one the "syslog" name (if it differs)
and the third one the "perl" name, suggesting (only!) that you log C<die>
( run in 0.642 second using v1.01-cache-2.11-cpan-49f99fa48dc )