OR-Tools  8.1
base/logging.cc File Reference

Go to the source code of this file.

Classes

struct  LogMessage::LogMessageData
 
class  LogDestination
 

Namespaces

 google
 
 google::base
 
 google::base::internal
 

Macros

#define _GNU_SOURCE   1
 
#define PATH_SEPARATOR   '/'
 
#define ATTRIBUTE_NORETURN   __attribute__((noreturn))
 
#define DEFINE_CHECK_STROP_IMPL(name, func, expected)
 

Typedefs

typedef void(* logging_fail_func_t) () ATTRIBUTE_NORETURN
 

Enumerations

enum  GLogColor { COLOR_DEFAULT, COLOR_RED, COLOR_GREEN, COLOR_YELLOW }
 

Functions

 ABSL_DECLARE_FLAG (bool, log_prefix)
 
 ABSL_DECLARE_FLAG (bool, logtostderr)
 
void FixFlagsAndEnvironmentForSwig ()
 
 ABSL_FLAG (bool, logtostderr, false, "log messages go to stderr instead of logfiles")
 
 ABSL_FLAG (bool, alsologtostderr, false, "log messages go to stderr in addition to logfiles")
 
 ABSL_FLAG (bool, colorlogtostderr, false, "color messages logged to stderr (if supported by terminal)")
 
 ABSL_FLAG (int, stderrthreshold, google::GLOG_ERROR, "log messages at or above this level are copied to stderr in " "addition to logfiles. This flag obsoletes --alsologtostderr.")
 
 ABSL_FLAG (bool, log_prefix, true, "Prepend the log prefix to the start of each log line")
 
 ABSL_FLAG (int, minloglevel, 0, "Messages logged at a lower level than this don't " "actually get logged anywhere")
 
 ABSL_FLAG (int, logbuflevel, 0, "Buffer log messages logged at this level or lower" " (-1 means don't buffer; 0 means buffer INFO only;" " ...)")
 
 ABSL_FLAG (int, logbufsecs, 30, "Buffer log messages for at most this many seconds")
 
static const char * DefaultLogDir ()
 
 ABSL_FLAG (int, logfile_mode, 0664, "Log file mode/permissions.")
 
 ABSL_FLAG (std::string, log_dir, DefaultLogDir(), "If specified, logfiles are written into this directory instead " "of the default logging directory.")
 
 ABSL_FLAG (std::string, log_link, "", "Put additional links to the log " "files in this directory")
 
 ABSL_FLAG (int, max_log_size, 1800, "approx. maximum log file size (in MB). A value of 0 will " "be silently overridden to 1.")
 
 ABSL_FLAG (bool, stop_logging_if_full_disk, false, "Stop attempting to log to disk if the disk is full.")
 
 ABSL_FLAG (std::string, log_backtrace_at, "", "Emit a backtrace when logging at file:linenum.")
 
static void GetHostName (string *hostname)
 
static bool TerminalSupportsColor ()
 
static GLogColor SeverityToColor (LogSeverity severity)
 
static const char * GetAnsiColorCode (GLogColor color)
 
static int32 MaxLogSize ()
 
const char * GetLogSeverityName (LogSeverity severity)
 
static void ColoredWriteToStderr (LogSeverity severity, const char *message, size_t len)
 
static void WriteToStderr (const char *message, size_t len)
 
void ReprintFatalMessage ()
 
static void logging_fail () ATTRIBUTE_NORETURN
 
void InstallFailureFunction (void(*fail_func)())
 
ostream & operator<< (ostream &os, const PRIVATE_Counter &)
 
void FlushLogFiles (LogSeverity min_severity)
 
void FlushLogFilesUnsafe (LogSeverity min_severity)
 
void SetLogDestination (LogSeverity severity, const char *base_filename)
 
void SetLogSymlink (LogSeverity severity, const char *symlink_basename)
 
void AddLogSink (LogSink *destination)
 
void RemoveLogSink (LogSink *destination)
 
void SetLogFilenameExtension (const char *ext)
 
void SetStderrLogging (LogSeverity min_severity)
 
void LogToStderr ()
 
bool GetExitOnDFatal ()
 
void SetExitOnDFatal (bool value)
 
static string ShellEscape (const string &src)
 
static void GetTempDirectories (vector< string > *list)
 
const vector< string > & GetLoggingDirectories ()
 
void TestOnly_ClearLoggingDirectoriesList ()
 
void GetExistingTempDirectories (vector< string > *list)
 
int posix_strerror_r (int err, char *buf, size_t len)
 
string StrError (int err)
 
template<>
void MakeCheckOpValueString (std::ostream *os, const char &v)
 
template<>
void MakeCheckOpValueString (std::ostream *os, const signed char &v)
 
template<>
void MakeCheckOpValueString (std::ostream *os, const unsigned char &v)
 
void InitGoogleLogging (const char *argv0)
 
void ShutdownGoogleLogging ()
 

Variables

static absl::Mutex log_mutex
 
static bool stop_writing = false
 
static bool exit_on_dfatal = true
 
static absl::Mutex fatal_msg_lock
 
static logging_internal::CrashReason crash_reason
 
static bool fatal_msg_exclusive = true
 
static LogMessage::LogMessageData fatal_msg_data_exclusive
 
static LogMessage::LogMessageData fatal_msg_data_shared
 
static thread_local bool thread_data_available = true
 
static thread_local std::aligned_storage< sizeof(LogMessage::LogMessageData), alignof(LogMessage::LogMessageData)>::type thread_msg_data
 
static time_t fatal_time
 
static char fatal_message [256]
 
GOOGLE_GLOG_DLL_DECL logging_fail_func_t g_logging_fail_func = &logging_fail
 
static const char kDontNeedShellEscapeChars []
 
static vector< string > * logging_directories_list
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE   1

Definition at line 16 of file base/logging.cc.

◆ ATTRIBUTE_NORETURN

#define ATTRIBUTE_NORETURN   __attribute__((noreturn))

Definition at line 1371 of file base/logging.cc.

◆ DEFINE_CHECK_STROP_IMPL

#define DEFINE_CHECK_STROP_IMPL (   name,
  func,
  expected 
)
Value:
string* Check##func##expected##Impl(const char* s1, const char* s2, \
const char* names) { \
bool equal = s1 == s2 || (s1 && s2 && !func(s1, s2)); \
if (equal == expected) { \
return NULL; \
} else { \
ostringstream ss; \
if (!s1) s1 = ""; \
if (!s2) s2 = ""; \
ss << #name " failed: " << names << " (" << s1 << " vs. " << s2 << ")"; \
return new string(ss.str()); \
} \
}

Definition at line 1728 of file base/logging.cc.

◆ PATH_SEPARATOR

#define PATH_SEPARATOR   '/'

Definition at line 176 of file base/logging.cc.

Function Documentation

◆ ABSL_DECLARE_FLAG() [1/2]

ABSL_DECLARE_FLAG ( bool  ,
log_prefix   
)

◆ ABSL_DECLARE_FLAG() [2/2]

ABSL_DECLARE_FLAG ( bool  ,
logtostderr   
)

◆ ABSL_FLAG() [1/14]

ABSL_FLAG ( bool  ,
alsologtostderr  ,
false  ,
"log messages go to stderr in addition to logfiles"   
)

◆ ABSL_FLAG() [2/14]

ABSL_FLAG ( bool  ,
colorlogtostderr  ,
false  ,
"color messages logged to stderr (if supported by terminal)"   
)

◆ ABSL_FLAG() [3/14]

ABSL_FLAG ( bool  ,
log_prefix  ,
true  ,
"Prepend the log prefix to the start of each log line"   
)

◆ ABSL_FLAG() [4/14]

ABSL_FLAG ( bool  ,
logtostderr  ,
false  ,
"log messages go to stderr instead of logfiles"   
)

◆ ABSL_FLAG() [5/14]

ABSL_FLAG ( bool  ,
stop_logging_if_full_disk  ,
false  ,
"Stop attempting to log to disk if the disk is full."   
)

◆ ABSL_FLAG() [6/14]

ABSL_FLAG ( int  ,
logbuflevel  ,
,
"Buffer log messages logged at this level or lower" " (-1 means don't buffer; 0 means buffer INFO only;" " ...)"   
)

◆ ABSL_FLAG() [7/14]

ABSL_FLAG ( int  ,
logbufsecs  ,
30  ,
"Buffer log messages for at most this many seconds"   
)

◆ ABSL_FLAG() [8/14]

ABSL_FLAG ( int  ,
logfile_mode  ,
0664  ,
"Log file mode/permissions."   
)

◆ ABSL_FLAG() [9/14]

ABSL_FLAG ( int  ,
max_log_size  ,
1800  ,
"approx. maximum log file size (in MB). A value of 0 will " "be silently overridden to 1."   
)

◆ ABSL_FLAG() [10/14]

ABSL_FLAG ( int  ,
minloglevel  ,
,
"Messages logged at a lower level than this don't " "actually get logged anywhere"   
)

◆ ABSL_FLAG() [11/14]

ABSL_FLAG ( int  ,
stderrthreshold  ,
google::GLOG_ERROR  ,
"log messages at or above this level are copied to stderr in " "addition to logfiles. This flag obsoletes --alsologtostderr."   
)

◆ ABSL_FLAG() [12/14]

ABSL_FLAG ( std::string  ,
log_backtrace_at  ,
""  ,
"Emit a backtrace when logging at file:linenum."   
)

◆ ABSL_FLAG() [13/14]

ABSL_FLAG ( std::string  ,
log_dir  ,
DefaultLogDir()  ,
"If  specified,
logfiles are written into this directory instead " "of the default logging directory."   
)

◆ ABSL_FLAG() [14/14]

ABSL_FLAG ( std::string  ,
log_link  ,
""  ,
"Put additional links to the log " "files in this directory"   
)

◆ DefaultLogDir()

static const char* DefaultLogDir ( )
static

Definition at line 141 of file base/logging.cc.

◆ FixFlagsAndEnvironmentForSwig()

void FixFlagsAndEnvironmentForSwig ( )

Definition at line 61 of file base/logging.cc.

◆ GetHostName()

static void GetHostName ( string *  hostname)
static

Definition at line 203 of file base/logging.cc.

◆ TerminalSupportsColor()

static bool TerminalSupportsColor ( )
static

Definition at line 223 of file base/logging.cc.

name
const std::string name
Definition: default_search.cc:808