Data-Printer

 view release on metacpan or  search on metacpan

lib/Data/Printer.pm  view on Meta::CPAN

    use DDP max_depth => 2, deparse => 1;

3. Setting custom properties on the actual call to C<p()> or C<np()>. This
overrides all other settings:

    p $var, show_tainted => 1, indent => 2;


=head2 The .dataprinter configuration file

The most powerful way to customize Data::Printer is to have a C<.dataprinter>
file in your home directory or your project's root directory. The format
is super simple and can be understood in the example below:

    # global settings (note that only full line comments are accepted)
    max_depth       = 1
    theme           = Monokai
    class.stringify = 0

    # use quotes if you want spaces to be significant:
    hash_separator  = " => "

    # You can set rules that apply only to a specific
    # caller module (in this case, MyApp::Some::Module):
    [MyApp::Some::Module]
    max_depth    = 2
    class.expand = 0
    escape_chars = nonlatin1

    [MyApp::Other::Module]
    multiline = 0
    output    = /var/log/myapp/debug.data

    # use 'quiet' to silence all output from p() and np()
    # called from the specified package.
    [MyApp::Yet::Another]
    quiet = 1

Note that if you set custom properties as arguments to C<p()> or C<np()>, you
should group suboptions as a hashref. So while the C<.dataprinter> file has
"C<< class.expand = 0 >>" and "C<< class.inherited = none >>", the equivalent
code is "C<< class => { expand => 0, inherited => 'none' } >>".

=head3 live updating your .dataprinter without restarts

Data::Printer 1.1 introduces a new 'live_update' flag that can be set to a
positive integer to enable live updates. When this mode is on, Data::Printer
will check if the C<.dataprinter> file has been updated and, if so, it will
reload it. This way you can toggle features on and off and control output
verbosity directly from your C<.dataprinter> file without needing to change
or restart running code.

=head2 Properties Quick Reference

Below are (almost) all available properties and their (hopefully sane)
default values. See L<Data::Printer::Object> for further information on
each of them:

    # scalar options
    show_tainted      = 1
    show_unicode      = 1
    show_lvalue       = 1
    print_escapes     = 0
    scalar_quotes     = "
    escape_chars      = none
    string_max        = 4096
    string_preserve   = begin
    string_overflow   = '(...skipping __SKIPPED__ chars...)'
    unicode_charnames = 0

    # array options
    array_max      = 100
    array_preserve = begin
    array_overflow = '(...skipping __SKIPPED__ items...)'
    index          = 1

    # hash options
    hash_max       = 100
    hash_preserve  = begin
    hash_overflow  = '(...skipping __SKIPPED__ keys...)'
    hash_separator = '   '
    align_hash     = 1
    sort_keys      = 1
    quote_keys     = auto

    # general options
    name           = var
    return_value   = pass
    output         = stderr
    use_prototypes = 1
    indent         = 4
    show_readonly  = 1
    show_tied      = 1
    show_dualvar   = lax
    show_weak      = 1
    show_refcount  = 0
    show_memsize   = 0
    memsize_unit   = auto
    separator      = ,
    end_separator  = 0
    caller_info    = 0
    caller_message = 'Printing in line __LINE__ of __FILENAME__'
    max_depth      = 0
    deparse        = 0
    alias          = p
    warnings       = 1

    # colorization (see Colors & Themes below)
    colored = auto
    theme   = Material

    # object output
    class_method             = _data_printer
    class.parents            = 1
    class.linear_isa         = auto
    class.universal          = 1
    class.expand             = 1
    class.stringify          = 1
    class.show_reftype       = 0
    class.show_overloads     = 1
    class.show_methods       = all
    class.sort_methods       = 1
    class.inherited          = none
    class.format_inheritance = string
    class.parent_filters     = 1
    class.internals          = 1


=head3 Settings' shortcuts



( run in 0.803 second using v1.01-cache-2.11-cpan-39bf76dae61 )