Project
Loading...
Searching...
No Matches
Signpost.h File Reference
#include "Framework/CompilerBuiltins.h"
#include <atomic>
#include <array>
#include <cassert>
#include <cinttypes>
#include <cstddef>

Go to the source code of this file.

Classes

struct  o2_log_handle_t
 
struct  _o2_lock_free_stack
 
struct  _o2_activity_t
 
struct  _o2_signpost_id_t
 
struct  _o2_log_t
 

Macros

#define O2_DECLARE_LOG_MAC(x, category)
 
#define O2_LOG_DEBUG_MAC(log, ...)
 
#define O2_SIGNPOST_EVENT_EMIT_MAC(log, id, name, format, ...)
 
#define O2_SIGNPOST_START_MAC(log, id, name, format, ...)
 
#define O2_SIGNPOST_END_MAC(log, id, name, format, ...)
 
#define O2_SIGNPOST_ENABLED_MAC(log)   false
 
#define O2_LOG_ENABLED(log)   private_o2_log_##log->stacktrace
 
#define O2_LOG_MACRO_RAW(level, format, ...)
 
#define O2_LOG_MACRO(...)
 
#define O2_DECLARE_DYNAMIC_LOG(name)   static _o2_log_t* private_o2_log_##name = (_o2_log_t*)_o2_log_create("ch.cern.aliceo2." #name, 1)
 
#define O2_DECLARE_DYNAMIC_STACKTRACE_LOG(name)   static _o2_log_t* private_o2_log_##name = (_o2_log_t*)_o2_log_create("ch.cern.aliceo2." #name, 64)
 For the moment we do not support logs with a stacktrace.
 
#define O2_DECLARE_LOG(name, category)   static _o2_log_t* private_o2_log_##name = (_o2_log_t*)_o2_log_create("ch.cern.aliceo2." #name, 1)
 
#define O2_LOG_ENABLE(log)   _o2_log_set_stacktrace(private_o2_log_##log, private_o2_log_##log->defaultStacktrace)
 
#define O2_LOG_DISABLE(log)   _o2_log_set_stacktrace(private_o2_log_##log, 0)
 
#define O2_LOG_DEBUG(log, ...)
 
#define O2_SIGNPOST_ID_FROM_POINTER(name, log, pointer)   _o2_signpost_id_t name = _o2_signpost_id_make_with_pointer(private_o2_log_##log, pointer)
 
#define O2_SIGNPOST_ID_GENERATE(name, log)   _o2_signpost_id_t name = _o2_signpost_id_generate_local(private_o2_log_##log)
 
#define O2_SIGNPOST_ACTION(log, callback)
 
#define O2_SIGNPOST_EVENT_EMIT(log, id, name, format, ...)
 
#define O2_SIGNPOST_EVENT_EMIT_INFO(log, id, name, format, ...)
 
#define O2_SIGNPOST_EVENT_EMIT_ERROR(log, id, name, format, ...)
 
#define O2_SIGNPOST_EVENT_EMIT_WARN(log, id, name, format, ...)
 
#define O2_SIGNPOST_EVENT_EMIT_CRITICAL(log, id, name, format, ...)
 
#define O2_SIGNPOST_START(log, id, name, format, ...)
 
#define O2_SIGNPOST_END(log, id, name, format, ...)
 

Typedefs

using _o2_signpost_index_t = int
 

Functions

template<auto N>
consteval auto remove_engineering_type (char const (&src)[N])
 
std::atomic< o2_log_handle_t * > & o2_get_logs_tail ()
 
o2_log_handle_to2_walk_logs (bool(*callback)(char const *name, void *log, void *context), void *context=nullptr)
 
bool _o2_lock_free_stack_push (_o2_lock_free_stack &stack, const int &value, bool spin=false)
 
bool _o2_lock_free_stack_pop (_o2_lock_free_stack &stack, int &value, bool spin=false)
 
void_o2_log_create (char const *name, int stacktrace)
 
void _o2_signpost_event_emit (_o2_log_t *log, _o2_signpost_id_t id, char const *name, char const *const format,...)
 
void _o2_singpost_action (_o2_log_t *log, void(*callback)(void *))
 
void _o2_signpost_interval_begin (_o2_log_t *log, _o2_signpost_id_t id, char const *name, char const *const format,...)
 
void _o2_signpost_interval_end (_o2_log_t *log, _o2_signpost_id_t id, char const *name, char const *const format,...)
 
void _o2_log_set_stacktrace (_o2_log_t *log, int stacktrace)
 
void _o2_signpost_action (_o2_log_t *log, void(*callback)(void *))
 
_o2_signpost_id_t _o2_signpost_id_generate_local (_o2_log_t *log)
 
_o2_signpost_id_t _o2_signpost_id_make_with_pointer (_o2_log_t *log, void const *pointer)
 

Macro Definition Documentation

◆ O2_DECLARE_DYNAMIC_LOG

#define O2_DECLARE_DYNAMIC_LOG (   name)    static _o2_log_t* private_o2_log_##name = (_o2_log_t*)_o2_log_create("ch.cern.aliceo2." #name, 1)

Dynamic logs need to be enabled via the O2_LOG_ENABLE macro. Notice this will only work for the logger based logging, since the Apple version needs instruments to enable them.

Definition at line 483 of file Signpost.h.

◆ O2_DECLARE_DYNAMIC_STACKTRACE_LOG

#define O2_DECLARE_DYNAMIC_STACKTRACE_LOG (   name)    static _o2_log_t* private_o2_log_##name = (_o2_log_t*)_o2_log_create("ch.cern.aliceo2." #name, 64)

For the moment we do not support logs with a stacktrace.

Definition at line 485 of file Signpost.h.

◆ O2_DECLARE_LOG

#define O2_DECLARE_LOG (   name,
  category 
)    static _o2_log_t* private_o2_log_##name = (_o2_log_t*)_o2_log_create("ch.cern.aliceo2." #name, 1)

Definition at line 486 of file Signpost.h.

◆ O2_DECLARE_LOG_MAC

#define O2_DECLARE_LOG_MAC (   x,
  category 
)

Definition at line 100 of file Signpost.h.

◆ O2_LOG_DEBUG

#define O2_LOG_DEBUG (   log,
  ... 
)
Value:
__extension__({ \
O2_LOG_MACRO(__VA_ARGS__); \
} else if (O2_BUILTIN_UNLIKELY(private_o2_log_##log->stacktrace)) { \
O2_LOG_MACRO(__VA_ARGS__); \
} \
})
#define O2_BUILTIN_UNLIKELY(x)
#define O2_LOG_ENABLED(log)
Definition Signpost.h:110

Definition at line 492 of file Signpost.h.

◆ O2_LOG_DEBUG_MAC

#define O2_LOG_DEBUG_MAC (   log,
  ... 
)

Definition at line 101 of file Signpost.h.

◆ O2_LOG_DISABLE

#define O2_LOG_DISABLE (   log)    _o2_log_set_stacktrace(private_o2_log_##log, 0)

Definition at line 489 of file Signpost.h.

◆ O2_LOG_ENABLE

#define O2_LOG_ENABLE (   log)    _o2_log_set_stacktrace(private_o2_log_##log, private_o2_log_##log->defaultStacktrace)

Definition at line 488 of file Signpost.h.

◆ O2_LOG_ENABLED

#define O2_LOG_ENABLED (   log)    private_o2_log_##log->stacktrace

Definition at line 110 of file Signpost.h.

◆ O2_LOG_MACRO

#define O2_LOG_MACRO (   ...)
Value:
do { \
printf(__VA_ARGS__); \
printf("\n"); \
} while (0)

Definition at line 136 of file Signpost.h.

◆ O2_LOG_MACRO_RAW

#define O2_LOG_MACRO_RAW (   level,
  format,
  ... 
)
Value:
do { \
printf(#level ":" #format, __VA_ARGS__); \
printf("\n"); \
} while (0)
GLint GLint GLsizei GLint GLenum format
Definition glcorearb.h:275

Definition at line 121 of file Signpost.h.

◆ O2_SIGNPOST_ACTION

#define O2_SIGNPOST_ACTION (   log,
  callback 
)
Value:
__extension__({ \
_o2_signpost_action(private_o2_log_##log, callback); \
} else if (O2_BUILTIN_UNLIKELY(private_o2_log_##log->stacktrace)) { \
_o2_signpost_action(private_o2_log_##log, callback); \
} \
})
#define O2_SIGNPOST_ENABLED_MAC(log)
Definition Signpost.h:105

Definition at line 504 of file Signpost.h.

◆ O2_SIGNPOST_ENABLED_MAC

#define O2_SIGNPOST_ENABLED_MAC (   log)    false

Definition at line 105 of file Signpost.h.

◆ O2_SIGNPOST_END

#define O2_SIGNPOST_END (   log,
  id,
  name,
  format,
  ... 
)
Value:
O2_SIGNPOST_END_MAC(log, id, name, format, ##__VA_ARGS__); \
} else if (O2_BUILTIN_UNLIKELY(private_o2_log_##log->stacktrace)) { \
_o2_signpost_interval_end(private_o2_log_##log, id, name, remove_engineering_type(format).data(), ##__VA_ARGS__); \
}
consteval auto remove_engineering_type(char const (&src)[N])
Definition Signpost.h:30
GLuint const GLchar * name
Definition glcorearb.h:781
GLboolean * data
Definition glcorearb.h:298

Definition at line 571 of file Signpost.h.

◆ O2_SIGNPOST_END_MAC

#define O2_SIGNPOST_END_MAC (   log,
  id,
  name,
  format,
  ... 
)

Definition at line 104 of file Signpost.h.

◆ O2_SIGNPOST_EVENT_EMIT

#define O2_SIGNPOST_EVENT_EMIT (   log,
  id,
  name,
  format,
  ... 
)
Value:
__extension__({ \
O2_SIGNPOST_EVENT_EMIT_MAC(log, id, name, format, ##__VA_ARGS__); \
} else if (O2_BUILTIN_UNLIKELY(private_o2_log_##log->stacktrace)) { \
_o2_signpost_event_emit(private_o2_log_##log, id, name, remove_engineering_type(format).data(), ##__VA_ARGS__); \
} \
})

Definition at line 516 of file Signpost.h.

◆ O2_SIGNPOST_EVENT_EMIT_CRITICAL

#define O2_SIGNPOST_EVENT_EMIT_CRITICAL (   log,
  id,
  name,
  format,
  ... 
)
Value:
__extension__({ \
O2_SIGNPOST_EVENT_EMIT_MAC(log, id, name, format, ##__VA_ARGS__); \
} else if (O2_BUILTIN_UNLIKELY(private_o2_log_##log->stacktrace)) { \
_o2_signpost_event_emit(private_o2_log_##log, id, name, remove_engineering_type(format).data(), ##__VA_ARGS__); \
} \
O2_LOG_MACRO_RAW(critical, remove_engineering_type(format).data(), ##__VA_ARGS__); \
})

Definition at line 556 of file Signpost.h.

◆ O2_SIGNPOST_EVENT_EMIT_ERROR

#define O2_SIGNPOST_EVENT_EMIT_ERROR (   log,
  id,
  name,
  format,
  ... 
)
Value:
__extension__({ \
O2_SIGNPOST_EVENT_EMIT_MAC(log, id, name, format, ##__VA_ARGS__); \
} else if (O2_BUILTIN_UNLIKELY(private_o2_log_##log->stacktrace)) { \
_o2_signpost_event_emit(private_o2_log_##log, id, name, remove_engineering_type(format).data(), ##__VA_ARGS__); \
} \
O2_LOG_MACRO_RAW(error, remove_engineering_type(format).data(), ##__VA_ARGS__); \
})

Definition at line 536 of file Signpost.h.

◆ O2_SIGNPOST_EVENT_EMIT_INFO

#define O2_SIGNPOST_EVENT_EMIT_INFO (   log,
  id,
  name,
  format,
  ... 
)
Value:
__extension__({ \
O2_SIGNPOST_EVENT_EMIT_MAC(log, id, name, format, ##__VA_ARGS__); \
} else if (O2_BUILTIN_UNLIKELY(private_o2_log_##log->stacktrace)) { \
_o2_signpost_event_emit(private_o2_log_##log, id, name, remove_engineering_type(format).data(), ##__VA_ARGS__); \
} else { \
O2_LOG_MACRO_RAW(info, remove_engineering_type(format).data(), ##__VA_ARGS__); \
} \
})

Definition at line 525 of file Signpost.h.

◆ O2_SIGNPOST_EVENT_EMIT_MAC

#define O2_SIGNPOST_EVENT_EMIT_MAC (   log,
  id,
  name,
  format,
  ... 
)

Definition at line 102 of file Signpost.h.

◆ O2_SIGNPOST_EVENT_EMIT_WARN

#define O2_SIGNPOST_EVENT_EMIT_WARN (   log,
  id,
  name,
  format,
  ... 
)
Value:
__extension__({ \
O2_SIGNPOST_EVENT_EMIT_MAC(log, id, name, format, ##__VA_ARGS__); \
} else if (O2_BUILTIN_UNLIKELY(private_o2_log_##log->stacktrace)) { \
_o2_signpost_event_emit(private_o2_log_##log, id, name, remove_engineering_type(format).data(), ##__VA_ARGS__); \
} \
O2_LOG_MACRO_RAW(warn, remove_engineering_type(format).data(), ##__VA_ARGS__); \
})

Definition at line 546 of file Signpost.h.

◆ O2_SIGNPOST_ID_FROM_POINTER

#define O2_SIGNPOST_ID_FROM_POINTER (   name,
  log,
  pointer 
)    _o2_signpost_id_t name = _o2_signpost_id_make_with_pointer(private_o2_log_##log, pointer)

Definition at line 499 of file Signpost.h.

◆ O2_SIGNPOST_ID_GENERATE

#define O2_SIGNPOST_ID_GENERATE (   name,
  log 
)    _o2_signpost_id_t name = _o2_signpost_id_generate_local(private_o2_log_##log)

Definition at line 500 of file Signpost.h.

◆ O2_SIGNPOST_START

#define O2_SIGNPOST_START (   log,
  id,
  name,
  format,
  ... 
)
Value:
O2_SIGNPOST_START_MAC(log, id, name, format, ##__VA_ARGS__); \
} else if (O2_BUILTIN_UNLIKELY(private_o2_log_##log->stacktrace)) { \
_o2_signpost_interval_begin(private_o2_log_##log, id, name, remove_engineering_type(format).data(), ##__VA_ARGS__); \
}

Definition at line 565 of file Signpost.h.

◆ O2_SIGNPOST_START_MAC

#define O2_SIGNPOST_START_MAC (   log,
  id,
  name,
  format,
  ... 
)

Definition at line 103 of file Signpost.h.

Typedef Documentation

◆ _o2_signpost_index_t

Definition at line 162 of file Signpost.h.

Function Documentation

◆ _o2_lock_free_stack_pop()

bool _o2_lock_free_stack_pop ( _o2_lock_free_stack stack,
int value,
bool  spin = false 
)

◆ _o2_lock_free_stack_push()

bool _o2_lock_free_stack_push ( _o2_lock_free_stack stack,
const int value,
bool  spin = false 
)

◆ _o2_log_create()

void * _o2_log_create ( char const *  name,
int  stacktrace 
)

◆ _o2_log_set_stacktrace()

void _o2_log_set_stacktrace ( _o2_log_t log,
int  stacktrace 
)

◆ _o2_signpost_action()

void _o2_signpost_action ( _o2_log_t log,
void(*)(void *)  callback 
)
inline

Definition at line 214 of file Signpost.h.

◆ _o2_signpost_event_emit()

void _o2_signpost_event_emit ( _o2_log_t log,
_o2_signpost_id_t  id,
char const *  name,
char const *const  format,
  ... 
)

◆ _o2_signpost_id_generate_local()

_o2_signpost_id_t _o2_signpost_id_generate_local ( _o2_log_t log)
inline

Definition at line 226 of file Signpost.h.

◆ _o2_signpost_id_make_with_pointer()

_o2_signpost_id_t _o2_signpost_id_make_with_pointer ( _o2_log_t log,
void const *  pointer 
)
inline

Definition at line 233 of file Signpost.h.

◆ _o2_signpost_interval_begin()

void _o2_signpost_interval_begin ( _o2_log_t log,
_o2_signpost_id_t  id,
char const *  name,
char const *const  format,
  ... 
)

◆ _o2_signpost_interval_end()

void _o2_signpost_interval_end ( _o2_log_t log,
_o2_signpost_id_t  id,
char const *  name,
char const *const  format,
  ... 
)

◆ _o2_singpost_action()

void _o2_singpost_action ( _o2_log_t log,
void(*)(void *)  callback 
)

◆ o2_get_logs_tail()

std::atomic< o2_log_handle_t * > & o2_get_logs_tail ( )

◆ o2_walk_logs()

o2_log_handle_t * o2_walk_logs ( bool(*)(char const *name, void *log, void *context)  callback,
void context = nullptr 
)

◆ remove_engineering_type()

template<auto N>
consteval auto remove_engineering_type ( char const (&)  src[N])

Definition at line 30 of file Signpost.h.