Log::ger::Manual::Tutorial::01_WhatIsLogging - What is logging? Why logging? Logging vs ...
version 0.023.000
Logging is recording information during run-time. You can log any kind of information, from dumping internal data structures and tracing the flow of program execution (for debugging purposes), showing the progress of activities (for verbose output a.k.a. progress report to the user), and so on (auditing, accounting, security monitoring, source code documentation, etc).
With Log::ger, this is as simple as use-ing Log::ger and adding logging statements, for example:
use
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");
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.
perlancar <perlancar@cpan.org>
This software is copyright (c) 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.
To install Log::ger::Manual, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::ger::Manual
CPAN shell
perl -MCPAN -e shell install Log::ger::Manual
For more information on module installation, please visit the detailed CPAN module installation guide.