Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 072caebf

Von Moritz Bunkus vor fast 8 Jahren hinzugefügt

  • ID 072caebf05b59b8b74f7f5699d99129834bab616
  • Vorgänger e39679e4
  • Nachfolger a8cba95a

LXDebug: Flag SHOW_CALLER für Ausgabe Dateiname:Zeilennummer bei message() & dump()

Unterschiede anzeigen:

SL/LXDebug.pm
11 11
use constant REQUEST            =>  1 << 7;
12 12
use constant WARN               =>  1 << 8;
13 13
use constant TRACE2             =>  1 << 9;
14
use constant ALL                => (1 << 10) - 1;
14
use constant SHOW_CALLER        =>  1 << 10;
15
use constant ALL                => (1 << 11) - 1;
15 16
use constant DEVEL              => INFO | DEBUG1 | QUERY | TRACE | BACKTRACE_ON_ERROR | REQUEST_TIMER;
16 17

  
17 18
use constant FILE_TARGET   => 0;
......
144 145
  no warnings;
145 146
  my ($self, $level, $message) = @_;
146 147

  
147
  $self->_write(level2string($level), $message) if (($self->{"level"} | $global_level) & $level || !$level);
148
  my $show_caller = ($level | $global_level) & SHOW_CALLER();
149
  $level         &= ~SHOW_CALLER();
150

  
151
  $self->_write(level2string($level), $message, show_caller => $show_caller) if (($self->{"level"} | $global_level) & $level || !$level);
148 152
}
149 153
sub warn {
150 154
  no warnings;
......
260 264

  
261 265
sub _write {
262 266
  no warnings;
263
  my ($self, $prefix, $message) = @_;
267
  my ($self, $prefix, $message, %options) = @_;
268

  
269
  my @prefixes = ($prefix);
270

  
271
  if ($options{show_caller}) {
272
    my ($package, $filename, $line, $subroutine) = caller(1);
273
    push @prefixes, "${filename}:${line}";
274
  }
275

  
276
  $prefix = join ' ', grep { $_ } @prefixes;
277

  
264 278
  my @now  = gettimeofday();
265 279
  my $date = strftime("%Y-%m-%d %H:%M:%S." . sprintf('%03d', int($now[1] / 1000)) . " $$ [" . getpid() . "] ${prefix}: ", localtime($now[0]));
266 280
  local *FILE;
config/kivitendo.conf.default
294 294
#   REQUEST            - Log each request. Careful! Passwords get filtered, but
295 295
#                        there may be confidential information being logged here
296 296
#   WARN               - warnings
297
#   SHOW_CALLER        - include the file name & line number from where a call
298
#                        to "message" or "dump" was called
297 299
#   ALL                - all possible debug messages
298 300
#
299 301
#   DEVEL              - sames as "INFO QUERY TRACE BACKTRACE_ON_ERROR REQUEST_TIMER"

Auch abrufbar als: Unified diff