MIP_SDK
v3.0.0-736-g212583cf
MicroStrain Communications Library for embedded systems
src
cpp
microstrain
logging.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
microstrain/logging.h
>
4
5
/*
6
namespace microstrain {
7
namespace logging {
8
12
13
// enum LogLevel : ::microstrain::C::microstrain_log_level
14
// {
15
// LEVEL_NONE = MICROSTRAIN_LOG_LEVEL_OFF,
16
// LEVEL_FATAL = MICROSTRAIN_LOG_LEVEL_FATAL,
17
// LEVEL_ERROR = MICROSTRAIN_LOG_LEVEL_ERROR,
18
// LEVEL_WARN = MICROSTRAIN_LOG_LEVEL_WARN,
19
// LEVEL_INFO = MICROSTRAIN_LOG_LEVEL_INFO,
20
// LEVEL_DEBUG = MICROSTRAIN_LOG_LEVEL_DEBUG,
21
// LEVEL_TRACE = MICROSTRAIN_LOG_LEVEL_TRACE,
22
// };
23
using Level = ::microstrain::C::microstrain_log_level;
24
25
using Callback = ::microstrain::C::microstrain_log_callback;
26
27
inline void init(Callback callback, Level max_level, void* user=nullptr)
28
{
29
return MICROSTRAIN_LOG_INIT(callback, max_level, user);
30
}
31
32
inline Callback get_callback()
33
{
34
#ifdef MICROSTRAIN_LOGGING_ENABLED
35
return ::microstrain::C::microstrain_logging_callback();
36
#else // !MICROSTRAIN_LOGGING_ENABLED
37
return nullptr;
38
#endif // MICROSTRAIN_LOGGING_ENABLED
39
}
40
41
inline Level max_level()
42
{
43
#ifdef MICROSTRAIN_LOGGING_ENABLED
44
return ::microstrain::C::microstrain_logging_level();
45
#else // !MICROSTRAIN_LOGGING_ENABLED
46
return LogLevel::OFF;
47
#endif // MICROSTRAIN_LOGGING_ENABLED
48
}
49
50
inline void* user_pointer()
51
{
52
#ifdef MICROSTRAIN_LOGGING_ENABLED
53
return ::microstrain::C::microstrain_logging_user_data();
54
#else // !MICROSTRAIN_LOGGING_ENABLED
55
return nullptr;
56
#endif // MICROSTRAIN_LOGGING_ENABLED
57
}
58
59
inline void log(Level level, const char* fmt, ...)
60
{
61
#ifdef MICROSTRAIN_LOGGING_ENABLED
62
va_list args;
63
va_start(args, fmt);
64
::microstrain::C::microstrain_logging_log_v(level, fmt, args);
65
va_end(args);
66
#endif // MICROSTRAIN_LOGGING_ENABLED
67
}
68
71
72
} // namespace logging
73
} // namespace microstrain
74
*/
logging.h
Generated by
1.8.17