1Agent::Tag(3) User Contributed Perl Documentation Agent::Tag(3)
2
3
4
6 Log::Agent::Tag - formats caller information
7
9 Intended to be inherited from
10
12 This class is meant to be inherited by all the classes implementing a
13 log message tag.
14
15 A message tag is a little string that is either appended or prepended
16 to all log messages.
17
18 For instance, and oversimplifying a bit, a tag meant to be prepended
19 will be inserted in front of the current log message, separated by
20 separator, which defaults to a single space:
21
22 +------------+-----------+---------------------------------+
23 | tag string | separator | current log message |
24 +------------+-----------+---------------------------------+
25
26 This operation is called tag insertion. The whole string then becomes
27 the current log message, and can be the target of another tag
28 insertion.
29
30 The reality is a little bit more complex, to allow successive tags to
31 be prepended or appended in the order they are specified, and not in
32 reverse order as they would be if naively implemented. See
33 Log::Agent::Message for the exact semantics of append() and prepend()
34 operations.
35
37 This section documents the interface provided to heirs, in case you
38 wish to implement your own tag class.
39
40 _init(name, postfix, separator)
41 Initialization routine that should be called by all heirs during
42 creation to initialize the common attributes.
43
44 postfix
45 When true, the tag is meant to be appended to the log message.
46 Otherwise, it is prepended.
47
48 name
49 The name of this tag. It is meant to provide by-name access to
50 tags, check whether a given tag is recorded, etc... The names
51 "caller" and "priority" are architecturally defined to refer to
52 "Log::Agent::Tag::Caller" and "Log::Agent::Tag::Priority" objects.
53
54 NOTE: Currently unused by any client code.
55
56 separator
57 The sperating string inserted between the tag and the log message.
58 It defaults to " " if not specified, i.e. left to "undef" when
59 calling _init().
60
61 string()
62 A deferred routine, to be implemented by heirs.
63
64 Returns the tag string only, without the separator, since its exact
65 placement depends on the value of the "postfix" attribute.
66
67 insert(message)
68 Insert this tag withing the "Log::Agent::Message" message,
69 according to the tag specifications (placement, separator). Calls
70 string() to produce the tag string.
71
72 This routine is frozen and should not be redefined by heirs.
73
75 Tagging classes define via their string() routine what is the string to
76 be used as a tag. The insertion of the tag within the log message is
77 done via a frozen routine from the "Log::Agent::Tag" ancestor.
78
79 The following classes are provided by "Log::Agent":
80
81 "Log::Agent::Tag::Callback"
82 The string() routine invokes a user-supplied callback, given as a
83 "Callback" object. You need the Callback module from CPAN if you
84 wish to use this class.
85
86 "Log::Agent::Tag::Caller"
87 Used internally to compute the caller and format it according to
88 user specifications.
89
90 "Log::Agent::Tag::Priority"
91 Used internally to format message priorities and add them to the
92 log messages.
93
94 "Log::Agent::Tag::String"
95 Defines a constant tagging string that should be added in all the
96 log messages, e.g. a web session ID.
97
99 Raphael Manfredi <Raphael_Manfredi@pobox.com>
100
102 Log::Agent::Message(3).
103
104
105
106perl v5.38.0 2023-07-20 Agent::Tag(3)