Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: master

Checking in changes prior to tagging of version 0.19.

Changelog diff is:

diff --git a/Changes b/Changes
index d988332..5634d21 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,12 @@ Revision history for Perl extension Log::Minimal


+0.19 2014-05-20T01:07:04Z
+        - Fix comma position of stack trace
+        - Fix documentation for autodump option
+          (Thank you moznion)
 0.18 2014-03-12T07:51:14Z

         - bug fix. croakf and croakff did not die on log level = NONE
latest commit f79582fa4b
@kazeburo authored
Failed to load latest commit information.
lib/Log Checking in changes prior to tagging of version 0.19.
t croakf and croakff are enabled on any log level
.gitignore minil migrate
Build.PL Checking in changes prior to tagging of version 0.19.
Changes Checking in changes prior to tagging of version 0.19.
META.json Checking in changes prior to tagging of version 0.19. Checking in changes prior to tagging of version 0.19.


Log::Minimal - Minimal but customizable logger.


use Log::Minimal;

critf("%s","foo"); # 2010-10-20T00:25:17 [CRITICAL] foo at line 12
warnf("%d %s %s", 1, "foo", $uri);
debugf("foo"); print if $ENV{LM_DEBUG} is true

# with full stack trace
# 2010-10-20T00:25:17 [CRITICAL] foo at lib/ line 10, line 12
warnff("%d %s %s", 1, "foo", $uri);
debugff("foo"); print if $ENV{LM_DEBUG} is true

my $serialize = ddf({ 'key' => 'value' });

# die with formatted message
croakff('%s %s', $code, $message);


Log::Minimal is Minimal but customizable log module.


  • critf(($message:Str|$format:Str,@list:Array));

    critf("could't connect to");
    critf("Connection timeout timeout:%d, host:%s", 2, "");

    Display CRITICAL messages. When two or more arguments are passed to the function, the first argument is treated as a format of printf.

    local $Log::Minimal::AUTODUMP = 1;
    critf({ foo => 'bar' });
    critf("dump is %s", { foo => 'bar' });

    If $Log::Minimal::AUTODUMP is true, reference or object message is serialized with Data::Dumper automatically.

  • warnf(($message:Str|$format:Str,@list:Array));

    Display WARN messages.

  • infof(($message:Str|$format:Str,@list:Array));

    Display INFO messages.

  • debugf(($message:Str|$format:Str,@list:Array));

    Display DEBUG messages, if $ENV{LM_DEBUG} is true.

  • critff(($message:Str|$format:Str,@list:Array));

    critff("could't connect to");
    critff("Connection timeout timeout:%d, host:%s", 2, "");

    Display CRITICAL messages with stack trace.

  • warnff(($message:Str|$format:Str,@list:Array));

    Display WARN messages with stack trace.

  • infoff(($message:Str|$format:Str,@list:Array));

    Display INFO messages with stack trace.

  • debugff(($message:Str|$format:Str,@list:Array));

    Display DEBUG messages with stack trace, if $ENV{LM_DEBUG} is true.

  • croakf(($message:Str|$format:Str,@list:Array));

    die with formatted $message

    croakf("critical error");
    # 2011-06-10T16:27:26 [ERROR] critical error at line 23
  • croakff(($message:Str|$format:Str,@list:Array));

    die with formatted $message with stack trace

  • ddf($value:Any)

    Utility method that serializes given value with Data::Dumper;

    my $serialize = ddf($hashref);



    To print debugf and debugff messages, $ENV{LM_DEBUG} must be true.

    You can change variable name from LM_DEBUG to arbitrary string which is specified by "env_debug" in use line. Changed variable name affects only in package locally.

    use Log::Minimal env_debug => 'FOO_DEBUG';
    $ENV{LM_DEBUG}  = 1;
    $ENV{FOO_DEBUG} = 0;
    debugf("hello"); # no output
    $ENV{FOO_DEBUG} = 1;
    debugf("world"); # print message

    $ENV{LM_COLOR} is used as default value of $Log::Minimal::COLOR


    $ENV{LM_DEFAULT_COLOR} is used as default value of $Log::Minimal::DEFAULT_COLOR

    Format of value is "LEVEL=FG;BG:LEVEL=FG;BG:...". "FG" and "BG" are optional.

    For example:

    export LM_DEFAULT_COLOR='debug=red:info=;cyan:critical=yellow;red'


  • $Log::Minimal::COLOR

    Coloring log messages. Disabled by default.

  • $Log::Minimal::PRINT

    To change the method of outputting the log, set $Log::Minimal::PRINT.

    # with PSGI Application. output log with request uri.
    my $app = sub {
        my $env = shift;
        local $Log::Minimal::PRINT = sub {
            my ( $time, $type, $message, $trace,$raw_message) = @_;
                "$time [$env->{SCRIPT_NAME}] [$type] $message at $trace\n");

    $message includes color sequences, If you want raw message text, use $raw_message. default is

    sub {
      my ( $time, $type, $message, $trace,$raw_message) = @_;
      warn "$time [$type] $message at $trace\n";
  • $Log::Minimal::DIE

    To change the format of die message, set $Log::Minimal::DIE.

    local $Log::Minimal::PRINT = sub {
        my ( $time, $type, $message, $trace) = @_;
        die "[$type] $message at $trace\n"; # not need time

    default is

    sub {
      my ( $time, $type, $message, $trace) = @_;
      die "$time [$type] $message at $trace\n";
  • $Log::Minimal::LOG_LEVEL

    Set level to output log.

    local $Log::Minimal::LOG_LEVEL = "WARN";
    infof("foo"); #print nothing

    Support levels are DEBUG,INFO,WARN,CRITICAL and NONE. If NONE is set, no output except croakf and croakff. Default log level is DEBUG.

  • $Log::Minimal::AUTODUMP

    Serialize message with Data::Dumper.

    warnf("%s", {foo => 'bar'}); # HASH(0x100804ed0)
    local $Log::Minimal::AUTODUMP = 1;
    warnf("dump is %s", {foo=>'bar'}); #dump is {foo=>'bar'}
    my $uri = URI->new("");
    warnf("uri: '%s'", $uri); # uri: ''

    If message is object and has overload methods like '""' or '0+', Log::Minimal uses it instead of Data::Dumper.

  • $Log::Minimal::TRACE_LEVEL

    Like a $Carp::CarpLevel, this variable determines how many additional call frames are to be skipped. Defaults to 0.

  • $Log::Minimal::ESCAPE_WHITESPACE

    If this value is true, whitespace other than space will be represented as [\n\t\r]. Defaults to 0.


Masahiro Nagano


Yuji Shimada (xaicron)

Yoshihiro Sugi (sugyan)



This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Something went wrong with that request. Please try again.