Logging Tap. Attach to a TreeNode to intercept logging messages from any NotificationSource nodes in the subtree of that node (including the node itself).
More...
#include <Tap.hpp>
|
| Tap (const Tap &)=delete |
| Disallow copy construction.
|
|
Tap & | operator= (const Tap &)=delete |
| Disallow copy assignment.
|
|
template<typename DestT > |
| Tap (TreeNode *node, const std::string *pcategory, DestT &dest) |
| Constructor.
|
|
template<typename DestT > |
| Tap (TreeNode *node, const std::string &category, DestT &dest) |
| Constructor.
|
|
template<typename DestT > |
| Tap (const std::string &category, DestT &dest) |
| Non-observing Constructor.
|
|
virtual | ~Tap () |
| Destructor.
|
|
void | reset (TreeNode *node) |
| Detach the tap from the current node (if any) and re-attach to a new node. Destination and category of observation is maintained.
|
|
void | detach () |
| Detach the tap from a node without destructing. Node can later be reattached to the same or another node using reset. Destination is maintained.
|
|
const std::string * | getCategoryID () const |
|
const std::string & | getCategoryName () const |
|
const Destination * | getDestination () const |
|
Destination * | getDestination () |
|
uint64_t | getNumMessages () const |
| Gets the number of messages seen by this tap having the designated category.
|
|
TreeNode * | getObservedNode () const |
| Gets the node at which this tap is observing.
|
|
bool | isObservedNodeExpired () const |
| Checks if the node at which this tap is observing has been deleted (i.e. its weak reference has expired)
|
|
Logging Tap. Attach to a TreeNode to intercept logging messages from any NotificationSource nodes in the subtree of that node (including the node itself).
- Note
- The creation and destruction of Taps is not thread-safe. Construction and destruction must be protected.
-
noncopyable
Definition at line 27 of file Tap.hpp.
◆ Tap() [1/3]
template<typename DestT >
sparta::log::Tap::Tap |
( |
TreeNode * |
node, |
|
|
const std::string * |
pcategory, |
|
|
DestT & |
dest |
|
) |
| |
|
inline |
Constructor.
- Template Parameters
-
- Parameters
-
node | Node that this tap will observe. Must not be nullptr |
pcategory | Category on which this node will filter. Must be interned in StringMananger. If the category string is not already known to be interned, use the alternate constructor for Tap. |
dest | Detination identifier (e.g. std::string filename or ostream&). See sparta::log::Destination and Destination.h for possible types. |
Example:
static StringManager & getStringManager()
Returns the StringManager singleton.
const std::string *const EMPTY
Holds interned empty strings.
std::string * internString(const std::string &s)
Stores a string in shared space within this manager unless it is already stored.
Logging Tap. Attach to a TreeNode to intercept logging messages from any NotificationSource nodes in ...
static const std::string *const WARN
Indicates a WARNING.
Definition at line 56 of file Tap.hpp.
◆ Tap() [2/3]
template<typename DestT >
sparta::log::Tap::Tap |
( |
TreeNode * |
node, |
|
|
const std::string & |
category, |
|
|
DestT & |
dest |
|
) |
| |
|
inline |
Constructor.
Example:
Tap t(root.getChild(
"a.b.c"),
"",
"out.log");
Tap t(root.getChild(
"a.b.c"),
"warning", std::cerr);
Tap t(root.getChild(
"a.b.c"),
"hello",
"out.log");
Definition at line 82 of file Tap.hpp.
◆ Tap() [3/3]
template<typename DestT >
sparta::log::Tap::Tap |
( |
const std::string & |
category, |
|
|
DestT & |
dest |
|
) |
| |
|
inline |
Non-observing Constructor.
Category and destination must be defined here, but node at which to observe can be specified later via reset.
Example:
Tap t(
"warning", std::cerr);
Tap t(
"hello",
"out.log");
t.reset(root.getChild("a.b.c");
Definition at line 103 of file Tap.hpp.
◆ ~Tap()
virtual sparta::log::Tap::~Tap |
( |
| ) |
|
|
inlinevirtual |
Destructor.
- Note
- Does not affect destination
Definition at line 116 of file Tap.hpp.
◆ detach()
void sparta::log::Tap::detach |
( |
| ) |
|
|
inline |
Detach the tap from a node without destructing. Node can later be reattached to the same or another node using reset. Destination is maintained.
This method exists to stop observing without having to delete any dynamically allocated taps.
Definition at line 150 of file Tap.hpp.
◆ getCategoryID()
const std::string * sparta::log::Tap::getCategoryID |
( |
| ) |
const |
|
inline |
◆ getCategoryName()
const std::string & sparta::log::Tap::getCategoryName |
( |
| ) |
const |
|
inline |
◆ getDestination() [1/2]
◆ getDestination() [2/2]
const Destination * sparta::log::Tap::getDestination |
( |
| ) |
const |
|
inline |
◆ getNumMessages()
uint64_t sparta::log::Tap::getNumMessages |
( |
| ) |
const |
|
inline |
Gets the number of messages seen by this tap having the designated category.
This is the number of messages forwarded to a destination by this tap.
Definition at line 196 of file Tap.hpp.
◆ getObservedNode()
TreeNode * sparta::log::Tap::getObservedNode |
( |
| ) |
const |
|
inline |
Gets the node at which this tap is observing.
- Note
- This node may have been deleted. To ensure this is safe, use isObservedNodeExpired
Definition at line 205 of file Tap.hpp.
◆ isObservedNodeExpired()
bool sparta::log::Tap::isObservedNodeExpired |
( |
| ) |
const |
|
inline |
Checks if the node at which this tap is observing has been deleted (i.e. its weak reference has expired)
Definition at line 213 of file Tap.hpp.
◆ reset()
void sparta::log::Tap::reset |
( |
TreeNode * |
node | ) |
|
|
inline |
Detach the tap from the current node (if any) and re-attach to a new node. Destination and category of observation is maintained.
- Parameters
-
node | The node to attach to. If null, this call effectively behaves like detach. |
- Note
- Destination and category were set in constructor
Definition at line 128 of file Tap.hpp.
◆ send_()
Actually send the notification.
- Parameters
-
origin | Node from which this notification (log message) was generated |
obs_pt_DO_NOT_USE | Node at which this tap was installed causing that node or its ancestors to generate this notification (log message). This node may no longer exist at this time because this tap could outlive the node. So do not access this. This will match the node referenced by node_wptr_, so if it is needed, go through node_wptr_ which knows when the node has expired. |
- Note
- This is a notification callback handler
- Warning
- Because Taps can exist while a Tree is being destroyed, this function must not access the observation_point argument because it may not exist
Definition at line 234 of file Tap.hpp.
The documentation for this class was generated from the following file:
- /github/workspace/sparta/sparta/log/Tap.hpp