-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
12 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
/// [Logging and tracing include] | ||
#include <cubos/core/tel/level.hpp> | ||
#include <cubos/core/tel/logging.hpp> | ||
#include <cubos/core/tel/tracing.hpp> | ||
|
||
using cubos::core::tel::Level; | ||
using cubos::core::tel::Logger; | ||
using cubos::core::tel::SpanManager; | ||
/// [Logging and tracing include] | ||
|
||
int main() | ||
{ | ||
cubos::core::tel::Logger::level(cubos::core::tel::Logger::Level::Trace); | ||
cubos::core::tel::level(Level::Debug); | ||
|
||
/// [Using macros] | ||
CUBOS_SPAN_TRACE("this_wont_exist!"); | ||
|
||
CUBOS_INFO("hello from root span!"); // root span | ||
|
||
CUBOS_SPAN_INFO("main_span"); | ||
// With this macro, a new RAII guard is created. When dropped, exits the span. | ||
// This indicates that we are in the span for the current lexical scope. | ||
// Logs and metrics from here will be associated with 'main' span. | ||
CUBOS_INFO("hello!"); | ||
|
||
CUBOS_SPAN_TRACE("other_scope"); | ||
CUBOS_SPAN_DEBUG("other_scope"); | ||
CUBOS_INFO("hello again!"); | ||
// ... | ||
/// [Using macros] | ||
|
||
/// [Manually] | ||
SpanManager::Span span("manual_span", CUBOS_SPAN_LEVEL_DEBUG, __FILE__, __LINE__); | ||
SpanManager::enter(&span); | ||
SpanManager::begin("manual_span", cubos::core::tel::Level::Debug); | ||
CUBOS_INFO("entered a manual span"); | ||
|
||
SpanManager::exit(); | ||
SpanManager::end(); | ||
CUBOS_INFO("after exit manual span"); | ||
/// [Manually] | ||
} | ||
} |