Add logging framework.

DEBUG messages are completely optimized out if NDEBUG is defined.
This commit is contained in:
Peter Johnson
2015-07-31 22:41:26 -07:00
parent afcfdb13a0
commit 4356e313ec
9 changed files with 143 additions and 25 deletions

View File

@@ -35,6 +35,19 @@ enum NT_EntryFlags {
NT_PERSISTENT = 0x01
};
/** NetworkTables logging levels. */
enum NT_LogLevel {
NT_LOG_CRITICAL = 50,
NT_LOG_ERROR = 40,
NT_LOG_WARNING = 30,
NT_LOG_INFO = 20,
NT_LOG_DEBUG = 10,
NT_LOG_DEBUG1 = 9,
NT_LOG_DEBUG2 = 8,
NT_LOG_DEBUG3 = 7,
NT_LOG_DEBUG4 = 6
};
/*
* Structures
*/
@@ -309,6 +322,11 @@ void NT_DisposeConnectionInfoArray(struct NT_ConnectionInfo *arr, size_t count);
/* timestamp */
unsigned long long NT_Now(void);
/* logging */
typedef void (*NT_LogFunc)(unsigned int level, const char *file,
unsigned int line, const char *msg);
void NT_SetLogger(NT_LogFunc func, unsigned int min_level);
#ifdef __cplusplus
}
#endif

View File

@@ -220,6 +220,11 @@ const char* LoadPersistent(
/* timestamp */
unsigned long long Now();
/* logging */
typedef std::function<void(unsigned int level, const char* file,
unsigned int line, const char* msg)> LogFunc;
void SetLogger(LogFunc func, unsigned int min_level);
} // namespace nt
#endif /* NTCORE_CPP_H_ */