D'oh - Debug module that redirects STDOUT and STDERR
#!/usr/bin/perl use D'oh 'i_hate_this_program'; D'oh::stderr('/tmp/stderr'); # redirect all stderr to /tmp/stderr # print date and script name/pid to STDERR D'oh::date(); D'oh::stdout('/tmp/stdout'); # redirect all stderr to /tmp/stderr # print date and script name/pid to STDOUT D'oh::date('STDOUT'); i_hate_this_program({ arbitrary => ['structured data'] }); print "hellloooooo\n"; die "world"; __END__ $ tail /tmp/stdout # D'oh: myscript [16440]: 2018-06-19 02:45:16.678Z hellloooooo $ tail /tmp/stderr # D'oh: myscript [16440]: 2018-06-19 02:45:16.677Z [{"arbitrary":["structured data"]}] world at myscript line 15.
The module, when used, prints all STDERR or STDOUT to a given file, which is by default /tmp/D'oh.
STDERR
STDOUT
/tmp/D'oh
stderr(FILENAME) and stdout(FILENAME) start the redirection. Redirection is not reversible (unless you save-and-restore the filehandles yourself). If no FILENAME is provided, the default is used.
stderr(FILENAME)
stdout(FILENAME)
date prints a timestamp to STDERR (date('STDOUT') prints it to STDOUT).
date
date('STDOUT')
You can also dump random data as JSON to STDERR by calling any function name you want. Just import the name you want to use.
Chris Nandor, pudge@pobox.com, http://pudge.net/
Copyright (c) 1998-2018 Chris Nandor. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Version 1.00 (2018-06-18) Version 0.05 (1998-02-02)
To install D::oh, copy and paste the appropriate command in to your terminal.
cpanm
cpanm D::oh
CPAN shell
perl -MCPAN -e shell install D::oh
For more information on module installation, please visit the detailed CPAN module installation guide.