1Log::Message::Simple(3)User Contributed Perl DocumentatioLnog::Message::Simple(3)
2
3
4
6 Log::Message::Simple - Simplified interface to Log::Message
7
9 use Log::Message::Simple qw[msg error debug
10 carp croak cluck confess];
11
12 use Log::Message::Simple qw[:STD :CARP];
13
14 ### standard reporting functionality
15 msg( "Connecting to database", $verbose );
16 error( "Database connection failed: $@", $verbose );
17 debug( "Connection arguments were: $args", $debug );
18
19 ### standard carp functionality
20 carp( "Wrong arguments passed: @_" );
21 croak( "Fatal: wrong arguments passed: @_" );
22 cluck( "Wrong arguments passed -- including stacktrace: @_" );
23 confess("Fatal: wrong arguments passed -- including stacktrace: @_" );
24
25 ### retrieve individual message
26 my @stack = Log::Message::Simple->stack;
27 my @stack = Log::Message::Simple->flush;
28
29 ### retrieve the entire stack in printable form
30 my $msgs = Log::Message::Simple->stack_as_string;
31 my $trace = Log::Message::Simple->stack_as_string(1);
32
33 ### redirect output
34 local $Log::Message::Simple::MSG_FH = \*STDERR;
35 local $Log::Message::Simple::ERROR_FH = \*STDERR;
36 local $Log::Message::Simple::DEBUG_FH = \*STDERR;
37
38 ### force a stacktrace on error
39 local $Log::Message::Simple::STACKTRACE_ON_ERROR = 1
40
42 This module provides standardized logging facilities using the
43 "Log::Message" module.
44
46 msg("message string" [,VERBOSE])
47 Records a message on the stack, and prints it to "STDOUT" (or actually
48 $MSG_FH, see the "GLOBAL VARIABLES" section below), if the "VERBOSE"
49 option is true. The "VERBOSE" option defaults to false.
50
51 Exported by default, or using the ":STD" tag.
52
53 debug("message string" [,VERBOSE])
54 Records a debug message on the stack, and prints it to "STDOUT" (or
55 actually $DEBUG_FH, see the "GLOBAL VARIABLES" section below), if the
56 "VERBOSE" option is true. The "VERBOSE" option defaults to false.
57
58 Exported by default, or using the ":STD" tag.
59
60 error("error string" [,VERBOSE])
61 Records an error on the stack, and prints it to "STDERR" (or actually
62 $ERROR_FH, see the "GLOBAL VARIABLES" sections below), if the "VERBOSE"
63 option is true. The "VERBOSE" options defaults to true.
64
65 Exported by default, or using the ":STD" tag.
66
67 carp();
68 Provides functionality equal to "Carp::carp()" while still logging to
69 the stack.
70
71 Exported by using the ":CARP" tag.
72
73 croak();
74 Provides functionality equal to "Carp::croak()" while still logging to
75 the stack.
76
77 Exported by using the ":CARP" tag.
78
79 confess();
80 Provides functionality equal to "Carp::confess()" while still logging
81 to the stack.
82
83 Exported by using the ":CARP" tag.
84
85 cluck();
86 Provides functionality equal to "Carp::cluck()" while still logging to
87 the stack.
88
89 Exported by using the ":CARP" tag.
90
92 Log::Message::Simple->stack()
93 Retrieves all the items on the stack. Since "Log::Message::Simple" is
94 implemented using "Log::Message", consult its manpage for the function
95 "retrieve" to see what is returned and how to use the items.
96
97 Log::Message::Simple->stack_as_string([TRACE])
98 Returns the whole stack as a printable string. If the "TRACE" option is
99 true all items are returned with "Carp::longmess" output, rather than
100 just the message. "TRACE" defaults to false.
101
102 Log::Message::Simple->flush()
103 Removes all the items from the stack and returns them. Since
104 "Log::Message::Simple" is implemented using "Log::Message", consult
105 its manpage for the function "retrieve" to see what is returned and how
106 to use the items.
107
109 $ERROR_FH
110 This is the filehandle all the messages sent to "error()" are being
111 printed. This defaults to *STDERR.
112
113 $MSG_FH
114 This is the filehandle all the messages sent to "msg()" are being
115 printed. This default to *STDOUT.
116
117 $DEBUG_FH
118 This is the filehandle all the messages sent to "debug()" are being
119 printed. This default to *STDOUT.
120
121 $STACKTRACE_ON_ERROR
122 If this option is set to "true", every call to "error()" will
123 generate a stacktrace using "Carp::shortmess()". Defaults to
124 "false"
125
126
127
128perl v5.32.1 2021-01-27 Log::Message::Simple(3)