taco-db  0.1.0
Classes | Namespaces | Macros | Functions | Variables
logging.h File Reference

Logging component for TDB. More...

#include "utils/misc.h"
#include <iostream>
#include <absl/base/log_severity.h>
#include <absl/strings/str_format.h>

Go to the source code of this file.

Classes

class  taco::TDBError
 

Namespaces

 taco
 

Macros

#define LOG(level, ...)
 LOG(LogSeverity level, const char *fmt, ...) More...
 

Functions

void taco::LogError (LogSeverity severity, std::string &&msg)
 Logs a message (which may not be an error despite what the name suggests). More...
 
void taco::SetLogOutput (std::ostream *log_out)
 Sets the output stream where the log messages should be printed to. More...
 
void taco::RestoreLogOutput ()
 Restores the log output stream to std::cerr. More...
 
void taco::SetLogPrintMinSeverity (LogSeverity min_severity)
 Sets the minimum severity level of a log message to be printed. More...
 
void taco::DisableLogPrint ()
 Disable all log message printing. More...
 
void taco::SetSecondaryLogOutput (std::ostream *log_out, LogSeverity min_severity)
 Sets the secondary output stream where logs messages additionally prints with at least the specified severity. More...
 
void taco::ClearSecondaryLogOutput ()
 Clears the secondary output stream where logs messages additionally prints. More...
 

Variables

constexpr LogSeverity taco::kInfo = LogSeverity::kInfo
 
constexpr LogSeverity taco::kWarning = LogSeverity::kWarning
 
constexpr LogSeverity taco::kError = LogSeverity::kError
 
constexpr LogSeverity taco::kFatal = LogSeverity::kFatal
 
constexpr const size_t taco::log_msg_buf_size = 8192
 
constexpr const size_t taco::log_msg_max_len = log_msg_buf_size - 12
 

Detailed Description

Logging component for TDB.

This file does not include tdb.h at the beginning as it is always included into the project indirectly from base/tdb_base.h.

This file does not have a header guard intentionally. This must be included indirectly from base/tdb_base.h. Any definition in this file will be put in namespace taco.

Macro Definition Documentation

◆ LOG

#define LOG (   level,
  ... 
)
Value:
do { \
::taco::LogError(level, absl::StrFormat("[%s] " \
CAR(__VA_ARGS__), \
absl::LogSeverityName(level) \
IF_NONEMPTY_COMMA(CADR(__VA_ARGS__), ) CDR(__VA_ARGS__))); \
} while (0)
#define CDR(...)
Definition: misc.h:76
#define CAR
Definition: misc.h:75
#define CADR(...)
Definition: misc.h:83
#define IF_NONEMPTY_COMMA(arg, if_branch)
Definition: misc.h:37
void LogError(LogSeverity level, std::string &&str)
Logs a message (which may not be an error despite what the name suggests).
Definition: logging.cpp:29

LOG(LogSeverity level, const char *fmt, ...)

Note: fmt must be a string literal or an absl::string_view. The level variable is double evaluated.