Revision 5cc1afa0
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
SL/LXDebug.pm | ||
---|---|---|
331 | 331 |
} |
332 | 332 |
|
333 | 333 |
1; |
334 |
__END__ |
|
335 |
|
|
336 |
=pod |
|
337 |
|
|
338 |
=encoding utf8 |
|
339 |
|
|
340 |
=head1 NAME |
|
341 |
|
|
342 |
LXDebug - Lx-Office debugging facilities |
|
343 |
|
|
344 |
=head1 SYNOPSIS |
|
345 |
|
|
346 |
This module provides functions for debugging Lx-Office. An instance is |
|
347 |
always created as the global variable C<$::lxdebug> at the earliest |
|
348 |
possible moment. |
|
349 |
|
|
350 |
Debugging is mostly logging of information. Each log function has a |
|
351 |
I<level> and an I<object> to be logged. The configuration file as well |
|
352 |
as this module's functions determine which levels get logged, and |
|
353 |
which file they're logged to. |
|
354 |
|
|
355 |
=head1 LOG LEVELS |
|
356 |
|
|
357 |
The available log levels are: |
|
358 |
|
|
359 |
=over 4 |
|
360 |
|
|
361 |
=item C<NONE> |
|
362 |
|
|
363 |
Always output the message regardless of the active levels. Only use |
|
364 |
this temporarily. |
|
365 |
|
|
366 |
=item C<INFO> |
|
367 |
|
|
368 |
Informational, not an error, more important than C<DEBUG1>. |
|
369 |
|
|
370 |
=item C<DEBUG1> |
|
371 |
|
|
372 |
Important debugging information. |
|
373 |
|
|
374 |
=item C<DEBUG2> |
|
375 |
|
|
376 |
Less important debugging information that occurs often and spams the |
|
377 |
log. |
|
378 |
|
|
379 |
=item C<QUERY> |
|
380 |
|
|
381 |
Log all queries executed by the L<SL::DBUtils> utility methods. |
|
382 |
|
|
383 |
=item C<TRACE> |
|
384 |
|
|
385 |
Log sub calls and exits via the L<enter_sub>/L<leave_sub> functions. |
|
386 |
|
|
387 |
=item C<BACKTRACE_ON_ERROR> |
|
388 |
|
|
389 |
Log a stack trace when an error is output. |
|
390 |
|
|
391 |
=item C<REQUEST_TIMER> |
|
392 |
|
|
393 |
Log each request's total execution time when it finishes. |
|
394 |
|
|
395 |
=item C<WARN> |
|
396 |
|
|
397 |
Important warnings. |
|
398 |
|
|
399 |
=item C<ALL> |
|
400 |
|
|
401 |
All of the above. |
|
402 |
|
|
403 |
=item C<DEVEL> |
|
404 |
|
|
405 |
Shortcut for C<INFO | QUERY | TRACE | BACKTRACE_ON_ERROR | REQUEST_TIMER>. |
|
406 |
|
|
407 |
=back |
|
408 |
|
|
409 |
=head1 FUNCTIONS |
|
410 |
|
|
411 |
=over 4 |
|
412 |
|
|
413 |
=item C<enter_sub [$level]> |
|
414 |
|
|
415 |
=item C<leave_sub [$level]> |
|
416 |
|
|
417 |
Pairs of these can be put near the beginning/end of a sub. They'll |
|
418 |
cause a trace to be written to the log file if the C<TRACE> level is |
|
419 |
active. |
|
420 |
|
|
421 |
If C<$level> is given then the log messages will only be logged if an |
|
422 |
additional log level C<$level> is active as well. |
|
423 |
|
|
424 |
=item C<enable_sub_tracing> |
|
425 |
|
|
426 |
=item C<disable_sub_tracing> |
|
427 |
|
|
428 |
Enables/disables sub tracing with L<enter_sub>/L<leave_sub> temporarily. |
|
429 |
|
|
430 |
=item C<is_tracing_enabled> |
|
431 |
|
|
432 |
Returns whether or not the C<TRACE> debug level is active. |
|
433 |
|
|
434 |
=item C<show_backtrace [$force]> |
|
435 |
|
|
436 |
Logs a stack backtrace if C<$force> is trueish or if the log level |
|
437 |
C<BACKTRACE_ON_ERROR> is active. |
|
438 |
|
|
439 |
=item C<message $level, $message> |
|
440 |
|
|
441 |
Logs the message C<$message> if the log level C<$level> is active. The |
|
442 |
message will be prefixed with a word describing the log level. |
|
443 |
|
|
444 |
=item C<warn $message> |
|
445 |
|
|
446 |
Equivalent to C<message WARN(), $message>. |
|
447 |
|
|
448 |
=item C<dump $level, $name, $variable> |
|
449 |
|
|
450 |
Logs a message that the variable named C<$name> is dumped along with a |
|
451 |
dump of the variable C<$variable> created by the L<Data::Dumper> |
|
452 |
module. Will log a warning if said module is not available. Will only |
|
453 |
log if the log level C<$level> is active. |
|
454 |
|
|
455 |
=item C<dump_yaml $level, $name, $variable> |
|
456 |
|
|
457 |
Logs a message that the variable named C<$name> is dumped along with a |
|
458 |
dump of the variable C<$variable> created by the C<YAML> module. Will |
|
459 |
only log if the log level C<$level> is active. |
|
460 |
|
|
461 |
=item C<dump_sql $level, $prefix, $results> |
|
462 |
|
|
463 |
Dumps the result of an SQL query in tabular form. Will only log if the |
|
464 |
log level C<$level> is active. |
|
465 |
|
|
466 |
=item C<show_diff $level, $item1, $item2, %params> |
|
467 |
|
|
468 |
Logs a unified diff of the textual representations of C<$item1> and |
|
469 |
C<$item2>. Requires the module L<Text::Diff> and logs a warning if |
|
470 |
said module is not available. |
|
471 |
|
|
472 |
C<$item1> and C<$item2> are dumped via L<YAML::Dumper> before diffing |
|
473 |
if they're non-scalars. |
|
474 |
|
|
475 |
Will only log if the log level C<$level> is active. |
|
476 |
|
|
477 |
=item C<begin_request> |
|
478 |
|
|
479 |
=item C<end_request> |
|
480 |
|
|
481 |
=item C<log_time> |
|
482 |
|
|
483 |
=item C<set_request_timer> |
|
484 |
|
|
485 |
=item C<want_request_timer> |
|
486 |
|
|
487 |
Internal functions used to log the current request's exeuction time |
|
488 |
(log level C<REQUEST_TIMER>). |
|
489 |
|
|
490 |
=item C<get_request_time> |
|
491 |
|
|
492 |
Returns the current request's elapsed execution time in seconds. |
|
493 |
|
|
494 |
=item C<file [$file_name]> |
|
495 |
|
|
496 |
Sets and/or returns the file name this instance logs to. |
|
497 |
|
|
498 |
=item C<level_by_name $level[, $val]> |
|
499 |
|
|
500 |
Returns if a log level C<$level> is active. C<$level> is a string |
|
501 |
representation, not one of the level constants from above. |
|
502 |
|
|
503 |
If C<$val> is given then said level will be turned on (if C<$val> is |
|
504 |
trueish) or off (if C<$val> is falsish). |
|
505 |
|
|
506 |
=back |
|
507 |
|
|
508 |
=head1 BUGS |
|
509 |
|
|
510 |
Nothing here yet. |
|
511 |
|
|
512 |
=head1 AUTHOR |
|
513 |
|
|
514 |
Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>, |
|
515 |
Sven Schöling E<lt>s.schoeling@linet-services.deE<gt> |
|
516 |
|
|
517 |
=cut |
Auch abrufbar als: Unified diff
Dokumentation für SL/LXDebug.pm