Project
Loading...
Searching...
No Matches
test_SignpostLogger.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12// We need the implementation on Apple, to get the logger based signposts
13// We also need the implementation in release mode, because the logger based signposts are not available in the release build
14#if defined(__APPLE__) || defined(NDEBUG)
15#define O2_SIGNPOST_IMPLEMENTATION
16#endif
17#define O2_FORCE_LOGGER_SIGNPOST 1
18#include "Framework/Signpost.h"
19#include <iostream>
20
21O2_DECLARE_LOG(test_Signpost2, "my category2");
23
24int main(int argc, char** argv)
25{
26 O2_DECLARE_LOG(test_Signpost, "my category");
27 O2_DECLARE_DYNAMIC_LOG(test_SignpostDynamic);
28
29 std::cout << "Loggers: " << std::endl;
30 o2_walk_logs([](char const* name, void* log, void*) -> bool {
31 std::cout << " - name: " << name << " " << log << std::endl;
32 return true;
33 },
34 nullptr);
35
36 O2_LOG_DEBUG(test_Signpost, "%s %d", "test_Signpost", 1);
37 O2_SIGNPOST_ID_GENERATE(id, test_Signpost);
38 O2_SIGNPOST_ID_GENERATE(id2, test_Signpost);
39 O2_SIGNPOST_START(test_Signpost, id, "Test category", "This is a test signpost");
40 O2_SIGNPOST_START(test_Signpost, id2, "Test category", "A sepaarate interval");
41 O2_SIGNPOST_EVENT_EMIT(test_Signpost, id, "Test category", "An event in an interval");
42 O2_SIGNPOST_END(test_Signpost, id, "Test category", "End of the first interval");
43 O2_SIGNPOST_END(test_Signpost, id2, "Test category", "A sepaarate interval");
44 O2_SIGNPOST_ID_FROM_POINTER(id3, test_Signpost, &id2);
45 O2_SIGNPOST_START(test_Signpost, id3, "Test category", "A signpost interval from a pointer");
46 O2_SIGNPOST_END(test_Signpost, id3, "Test category", "A signpost interval from a pointer");
47
48 // This has an engineering type, which we will not use on Linux / FairLogger
49 O2_SIGNPOST_ID_FROM_POINTER(id4, test_Signpost, &id3);
50 O2_SIGNPOST_START(test_Signpost, id4, "Test category", "A signpost with an engineering type formatter %{size-in-bytes}d", 1);
51 O2_SIGNPOST_END(test_Signpost, id4, "Test category", "A signpost interval from a pointer");
52
53 O2_SIGNPOST_START(test_SignpostDynamic, id, "Test category", "This is dynamic signpost which you will not see, because they are off by default");
54 O2_SIGNPOST_END(test_SignpostDynamic, id, "Test category", "This is dynamic signpost which you will not see, because they are off by default");
55 O2_LOG_ENABLE(test_SignpostDynamic);
56#ifdef __APPLE__
57 // On Apple there is no way to turn on signposts in the logger, so we do not display this message
58 O2_SIGNPOST_START(test_SignpostDynamic, id, "Test category", "This is dynamic signpost which you will see, because we turned them on");
59 O2_SIGNPOST_END(test_SignpostDynamic, id, "Test category", "This is dynamic signpost which you will see, because we turned them on");
60#endif
61
62 // Test stacktraces
63 O2_SIGNPOST_ID_GENERATE(idStacktrace, SignpostStacktrace);
64 O2_LOG_ENABLE(SignpostStacktrace);
65 O2_SIGNPOST_EVENT_EMIT_ERROR(SignpostStacktrace, idStacktrace, "Test category", "An error with stacktrace %d \n", 1);
66}
#define O2_LOG_DEBUG(log,...)
Definition Signpost.h:482
#define O2_SIGNPOST_EVENT_EMIT_ERROR(log, id, name, format,...)
Definition Signpost.h:515
o2_log_handle_t * o2_walk_logs(bool(*callback)(char const *name, void *log, void *context), void *context=nullptr)
#define O2_DECLARE_DYNAMIC_LOG(name)
Definition Signpost.h:473
#define O2_SIGNPOST_ID_FROM_POINTER(name, log, pointer)
Definition Signpost.h:489
#define O2_SIGNPOST_END(log, id, name, format,...)
Definition Signpost.h:540
#define O2_DECLARE_DYNAMIC_STACKTRACE_LOG(name)
For the moment we do not support logs with a stacktrace.
Definition Signpost.h:475
#define O2_SIGNPOST_ID_GENERATE(name, log)
Definition Signpost.h:490
#define O2_DECLARE_LOG(name, category)
Definition Signpost.h:476
#define O2_LOG_ENABLE(log)
Definition Signpost.h:478
#define O2_SIGNPOST_EVENT_EMIT(log, id, name, format,...)
Definition Signpost.h:495
#define O2_SIGNPOST_START(log, id, name, format,...)
Definition Signpost.h:534
GLuint const GLchar * name
Definition glcorearb.h:781
#define main