use constant BACKTRACE_ON_ERROR => 1 << 5;
use constant REQUEST_TIMER => 1 << 6;
use constant WARN => 1 << 7;
-use constant ALL => (1 << 8) - 1;
-use constant DEVEL => INFO | QUERY | TRACE | BACKTRACE_ON_ERROR | REQUEST_TIMER;
+use constant TRACE2 => 1 << 8;
+use constant ALL => (1 << 9) - 1;
+use constant DEVEL => INFO | DEBUG1 | QUERY | TRACE | BACKTRACE_ON_ERROR | REQUEST_TIMER;
use constant FILE_TARGET => 0;
use constant STDERR_TARGET => 1;
my $level = shift || 0;
return 1 unless ($global_level & TRACE); # ignore if traces aren't active
- return 1 if $level && !($global_level & $level); # ignore if level of trace isn't active
+ return 1 if $level && !($global_level & TRACE2); # ignore if level of trace isn't active
my ($package, $filename, $line, $subroutine) = caller(1);
my ($dummy1, $self_filename, $self_line) = caller(0);
my $level = shift || 0;
return 1 unless ($global_level & TRACE); # ignore if traces aren't active
- return 1 if $level && !($global_level & $level); # ignore if level of trace isn't active
+ return 1 if $level && !($global_level & TRACE2); # ignore if level of trace isn't active
my ($package, $filename, $line, $subroutine) = caller(1);
my ($dummy1, $self_filename, $self_line) = caller(0);
my $indent = " " x --$self->{"calldepth"};
- my $time = $self->want_request_timer ? $self->get_request_time : '';
+ my $time = $self->want_request_timer ? $self->get_request_time || '' : '';
if (!defined($package)) {
$self->_write('sub' . $level, $indent . "/ $time top-level?\n");
chomp($message);
if ((FILE_TARGET == $self->{"target"})
- && open(FILE, ">>" . $self->{"file"})) {
+ && open(FILE, ">>", $self->{"file"})) {
print(FILE "${date}${message}\n");
close(FILE);
}
sub log_time {
- my $self = shift;
+ my ($self, @slurp) = @_;
return 1 unless want_request_timer();
- $self->_write("time", $self->get_request_time);
+ $self->_write("time", $self->get_request_time() . (@slurp ? " (@slurp)" : ''));
}
sub get_request_time {
=item C<TRACE>
-Log sub calls and exits via the L<enter_sub>/L<leave_sub> functions.
+Log sub calls and exits via the L<enter_sub>/L<leave_sub> functions,
+but only if they're called with a log level that is falsish
+(e.g. none, C<undef>, 0).
+
+=item C<TRACE2>
+
+Log sub calls and exits via the L<enter_sub>/L<leave_sub> functions
+even if they're called with a log level of 2. Will only have an effect
+if C<TRACE> is set as well.
=item C<BACKTRACE_ON_ERROR>
=back
+=head1 CONFIGURATION
+
+C<SL::LXDebug> gets its configuration from the C<[debug]> section of
+the C<config/kivitendo.conf> configuration file. The available options
+are:
+
+=over 4
+
+=item C<global_level>
+
+A string of log level names that should be activated by
+default. Multiple log levels are separated by C<|>.
+
+=item C<watch_form>
+
+A boolean (C<1> or C<0>). Turns on the C<$::form> watch facility. If
+this is enabled then any key inside C<$::form> can be monitored for
+changes. For example:
+
+ # Start watching 'action'
+ $::form->{"Watchdog::action"} = 1;
+ # Stop watching 'invtotal'
+ $::form->{"Watchdog::invtotal"} = 0;
+
+A log message is written when the watchdog is enabled for a variable
+and for each subsequent change. The log message includes the place
+(file name and line number) of the instruction changing the key.
+
+Note that this entails a performance penalty. Also only the keys
+themselves are monitored -- not the references they point to. E.g. the
+following would not trigger a change:
+
+ $::form->{"Watchdog::some_hash"} = 1;
+ # Does not trigger:
+ $::form->{some_hash}->{some_value} = 42;
+ # This does trigger:
+ $::form->{some_hash} = { something => 'else' };
+
+=item C<show_debug_menu>
+
+A boolean (C<1> or C<0>). If turned on then certain debug facilities
+are available from the v1 menu. These include e.g.
+
+=over 6
+
+=item *
+
+restarting the FastCGI process by forcefully exiting after the
+request,
+
+=item *
+
+enabling and disabling function tracing,
+
+=item *
+
+enabling and disabling certain debug levels.
+
+=back
+
+Note that these are only useful if Lx-Office is running as a FastCGI
+application because otherwise the changes would be lost when the
+process exits in a normal CGI environment.
+
+=item C<keep_temp_files>
+
+A boolean (C<1> or C<0>). If turned on then certain temporary files
+are not removed but kept in the C<users> directory. These include the
+temporary files used during printing, e.g. LaTeX files.
+
+=item C<file_name>
+
+The path and file name of the debug log file. Must be a location
+writeable by the web server process.
+
+=back
+
=head1 FUNCTIONS
=over 4
cause a trace to be written to the log file if the C<TRACE> level is
active.
-If C<$level> is given then the log messages will only be logged if an
-additional log level C<$level> is active as well.
+If C<$level> is given then the log messages will only be logged if the
+global log level C<TRACE2> is active as well.
=item C<enable_sub_tracing>