package Log::ger::Manual::Tutorial::100_WhatIsLogging;

# DATE
# VERSION

1;
# ABSTRACT: What is logging? Why logging? Logging vs ...

__END__

=pod

=encoding UTF-8

=head1 NAME

Log::ger::Manual::Tutorial::100_WhatIsLogging - What is logging? Why logging? Logging vs ...

=head1 VERSION

version 0.032.001

=head1 DESCRIPTION

=over

=back

=head1 WHAT IS LOGGING?

Logging is recording information during run-time. You can log any kind of
information for whatever purposes. Logging is most often used for debugging; you
can dump internal data structures, record warn/die message along with their
stack trace, or mark entering/leaving subroutines to trace the flow of program
execution. Logging can also be used to show the progress of a long-running
activity, to give users feedback so they know what's going on. Other uses of
logging include: auditing, accounting, security monitoring, source code
documentation, and so on.

To start logging with L<Log::ger>, all you have to do is C<use Log::ger> (or
C<require> I<and> C<import>) then start peppering logging statements. For
example:

 use Log::ger;

 sub process_user {
     log_trace("Entering process_user(%s)", \@_);

     ...

     log_trace("Leaving process_user(), result=%s", $res);
     return $res;
 }

 log_trace("Starting program");
 for my $user (@ARGV) {
     log_info("Processing user %s", $user);
     process_user($user);
 }
 log_trace("Ending program");

=head1 WHY LOGGING? LOGGING VS ...

Compared to using a debugger (with standard features like single-stepping,
breakpoints, watchpoints, etc), logging can help diagnose problems while you run
an application normally in production environment, as opposed to having to stop
a program and run it under the debugger. Of course, a proper debugger has its
strengths too.

Compared to peppering "print" statements all over your program, logging using a
framework brings the flexibility of turning on/off the statements according to
the notion of level/severity (or other criteria), and redirecting where the log
messages should go. On the other hand, "print" statement is simpler and does not
require extra module/framework.

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2020, 2019, 2018, 2017 by perlancar@cpan.org.

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
