|
Packit Service |
9def5d |
// This file is automatically generated from src/glog/raw_logging.h.in
|
|
Packit Service |
9def5d |
// using src/windows/preprocess.sh.
|
|
Packit Service |
9def5d |
// DO NOT EDIT!
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
// Copyright (c) 2006, Google Inc.
|
|
Packit Service |
9def5d |
// All rights reserved.
|
|
Packit Service |
9def5d |
//
|
|
Packit Service |
9def5d |
// Redistribution and use in source and binary forms, with or without
|
|
Packit Service |
9def5d |
// modification, are permitted provided that the following conditions are
|
|
Packit Service |
9def5d |
// met:
|
|
Packit Service |
9def5d |
//
|
|
Packit Service |
9def5d |
// * Redistributions of source code must retain the above copyright
|
|
Packit Service |
9def5d |
// notice, this list of conditions and the following disclaimer.
|
|
Packit Service |
9def5d |
// * Redistributions in binary form must reproduce the above
|
|
Packit Service |
9def5d |
// copyright notice, this list of conditions and the following disclaimer
|
|
Packit Service |
9def5d |
// in the documentation and/or other materials provided with the
|
|
Packit Service |
9def5d |
// distribution.
|
|
Packit Service |
9def5d |
// * Neither the name of Google Inc. nor the names of its
|
|
Packit Service |
9def5d |
// contributors may be used to endorse or promote products derived from
|
|
Packit Service |
9def5d |
// this software without specific prior written permission.
|
|
Packit Service |
9def5d |
//
|
|
Packit Service |
9def5d |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
Packit Service |
9def5d |
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
Packit Service |
9def5d |
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
Packit Service |
9def5d |
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
Packit Service |
9def5d |
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
Packit Service |
9def5d |
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
Packit Service |
9def5d |
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
Packit Service |
9def5d |
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
Packit Service |
9def5d |
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
Packit Service |
9def5d |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
Packit Service |
9def5d |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit Service |
9def5d |
//
|
|
Packit Service |
9def5d |
// Author: Maxim Lifantsev
|
|
Packit Service |
9def5d |
//
|
|
Packit Service |
9def5d |
// Thread-safe logging routines that do not allocate any memory or
|
|
Packit Service |
9def5d |
// acquire any locks, and can therefore be used by low-level memory
|
|
Packit Service |
9def5d |
// allocation and synchronization code.
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
#ifndef BASE_RAW_LOGGING_H_
|
|
Packit Service |
9def5d |
#define BASE_RAW_LOGGING_H_
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
#include <time.h>
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
namespace google {
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
#include "glog/log_severity.h"
|
|
Packit Service |
9def5d |
#include "glog/vlog_is_on.h"
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
// Annoying stuff for windows -- makes sure clients can import these functions
|
|
Packit Service |
9def5d |
#ifndef GOOGLE_GLOG_DLL_DECL
|
|
Packit Service |
9def5d |
# if defined(_WIN32) && !defined(__CYGWIN__)
|
|
Packit Service |
9def5d |
# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
|
|
Packit Service |
9def5d |
# else
|
|
Packit Service |
9def5d |
# define GOOGLE_GLOG_DLL_DECL
|
|
Packit Service |
9def5d |
# endif
|
|
Packit Service |
9def5d |
#endif
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
// This is similar to LOG(severity) << format... and VLOG(level) << format..,
|
|
Packit Service |
9def5d |
// but
|
|
Packit Service |
9def5d |
// * it is to be used ONLY by low-level modules that can't use normal LOG()
|
|
Packit Service |
9def5d |
// * it is desiged to be a low-level logger that does not allocate any
|
|
Packit Service |
9def5d |
// memory and does not need any locks, hence:
|
|
Packit Service |
9def5d |
// * it logs straight and ONLY to STDERR w/o buffering
|
|
Packit Service |
9def5d |
// * it uses an explicit format and arguments list
|
|
Packit Service |
9def5d |
// * it will silently chop off really long message strings
|
|
Packit Service |
9def5d |
// Usage example:
|
|
Packit Service |
9def5d |
// RAW_LOG(ERROR, "Failed foo with %i: %s", status, error);
|
|
Packit Service |
9def5d |
// RAW_VLOG(3, "status is %i", status);
|
|
Packit Service |
9def5d |
// These will print an almost standard log lines like this to stderr only:
|
|
Packit Service |
9def5d |
// E0821 211317 file.cc:123] RAW: Failed foo with 22: bad_file
|
|
Packit Service |
9def5d |
// I0821 211317 file.cc:142] RAW: status is 20
|
|
Packit Service |
9def5d |
#define RAW_LOG(severity, ...) \
|
|
Packit Service |
9def5d |
do { \
|
|
Packit Service |
9def5d |
switch (google::GLOG_ ## severity) { \
|
|
Packit Service |
9def5d |
case 0: \
|
|
Packit Service |
9def5d |
RAW_LOG_INFO(__VA_ARGS__); \
|
|
Packit Service |
9def5d |
break; \
|
|
Packit Service |
9def5d |
case 1: \
|
|
Packit Service |
9def5d |
RAW_LOG_WARNING(__VA_ARGS__); \
|
|
Packit Service |
9def5d |
break; \
|
|
Packit Service |
9def5d |
case 2: \
|
|
Packit Service |
9def5d |
RAW_LOG_ERROR(__VA_ARGS__); \
|
|
Packit Service |
9def5d |
break; \
|
|
Packit Service |
9def5d |
case 3: \
|
|
Packit Service |
9def5d |
RAW_LOG_FATAL(__VA_ARGS__); \
|
|
Packit Service |
9def5d |
break; \
|
|
Packit Service |
9def5d |
default: \
|
|
Packit Service |
9def5d |
break; \
|
|
Packit Service |
9def5d |
} \
|
|
Packit Service |
9def5d |
} while (0)
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
// The following STRIP_LOG testing is performed in the header file so that it's
|
|
Packit Service |
9def5d |
// possible to completely compile out the logging code and the log messages.
|
|
Packit Service |
9def5d |
#if STRIP_LOG == 0
|
|
Packit Service |
9def5d |
#define RAW_VLOG(verboselevel, ...) \
|
|
Packit Service |
9def5d |
do { \
|
|
Packit Service |
9def5d |
if (VLOG_IS_ON(verboselevel)) { \
|
|
Packit Service |
9def5d |
RAW_LOG_INFO(__VA_ARGS__); \
|
|
Packit Service |
9def5d |
} \
|
|
Packit Service |
9def5d |
} while (0)
|
|
Packit Service |
9def5d |
#else
|
|
Packit Service |
9def5d |
#define RAW_VLOG(verboselevel, ...) RawLogStub__(0, __VA_ARGS__)
|
|
Packit Service |
9def5d |
#endif // STRIP_LOG == 0
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
#if STRIP_LOG == 0
|
|
Packit Service |
9def5d |
#define RAW_LOG_INFO(...) google::RawLog__(google::GLOG_INFO, \
|
|
Packit Service |
9def5d |
__FILE__, __LINE__, __VA_ARGS__)
|
|
Packit Service |
9def5d |
#else
|
|
Packit Service |
9def5d |
#define RAW_LOG_INFO(...) google::RawLogStub__(0, __VA_ARGS__)
|
|
Packit Service |
9def5d |
#endif // STRIP_LOG == 0
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
#if STRIP_LOG <= 1
|
|
Packit Service |
9def5d |
#define RAW_LOG_WARNING(...) google::RawLog__(google::GLOG_WARNING, \
|
|
Packit Service |
9def5d |
__FILE__, __LINE__, __VA_ARGS__)
|
|
Packit Service |
9def5d |
#else
|
|
Packit Service |
9def5d |
#define RAW_LOG_WARNING(...) google::RawLogStub__(0, __VA_ARGS__)
|
|
Packit Service |
9def5d |
#endif // STRIP_LOG <= 1
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
#if STRIP_LOG <= 2
|
|
Packit Service |
9def5d |
#define RAW_LOG_ERROR(...) google::RawLog__(google::GLOG_ERROR, \
|
|
Packit Service |
9def5d |
__FILE__, __LINE__, __VA_ARGS__)
|
|
Packit Service |
9def5d |
#else
|
|
Packit Service |
9def5d |
#define RAW_LOG_ERROR(...) google::RawLogStub__(0, __VA_ARGS__)
|
|
Packit Service |
9def5d |
#endif // STRIP_LOG <= 2
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
#if STRIP_LOG <= 3
|
|
Packit Service |
9def5d |
#define RAW_LOG_FATAL(...) google::RawLog__(google::GLOG_FATAL, \
|
|
Packit Service |
9def5d |
__FILE__, __LINE__, __VA_ARGS__)
|
|
Packit Service |
9def5d |
#else
|
|
Packit Service |
9def5d |
#define RAW_LOG_FATAL(...) \
|
|
Packit Service |
9def5d |
do { \
|
|
Packit Service |
9def5d |
google::RawLogStub__(0, __VA_ARGS__); \
|
|
Packit Service |
9def5d |
exit(1); \
|
|
Packit Service |
9def5d |
} while (0)
|
|
Packit Service |
9def5d |
#endif // STRIP_LOG <= 3
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
// Similar to CHECK(condition) << message,
|
|
Packit Service |
9def5d |
// but for low-level modules: we use only RAW_LOG that does not allocate memory.
|
|
Packit Service |
9def5d |
// We do not want to provide args list here to encourage this usage:
|
|
Packit Service |
9def5d |
// if (!cond) RAW_LOG(FATAL, "foo ...", hard_to_compute_args);
|
|
Packit Service |
9def5d |
// so that the args are not computed when not needed.
|
|
Packit Service |
9def5d |
#define RAW_CHECK(condition, message) \
|
|
Packit Service |
9def5d |
do { \
|
|
Packit Service |
9def5d |
if (!(condition)) { \
|
|
Packit Service |
9def5d |
RAW_LOG(FATAL, "Check %s failed: %s", #condition, message); \
|
|
Packit Service |
9def5d |
} \
|
|
Packit Service |
9def5d |
} while (0)
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
// Debug versions of RAW_LOG and RAW_CHECK
|
|
Packit Service |
9def5d |
#ifndef NDEBUG
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
#define RAW_DLOG(severity, ...) RAW_LOG(severity, __VA_ARGS__)
|
|
Packit Service |
9def5d |
#define RAW_DCHECK(condition, message) RAW_CHECK(condition, message)
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
#else // NDEBUG
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
#define RAW_DLOG(severity, ...) \
|
|
Packit Service |
9def5d |
while (false) \
|
|
Packit Service |
9def5d |
RAW_LOG(severity, __VA_ARGS__)
|
|
Packit Service |
9def5d |
#define RAW_DCHECK(condition, message) \
|
|
Packit Service |
9def5d |
while (false) \
|
|
Packit Service |
9def5d |
RAW_CHECK(condition, message)
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
#endif // NDEBUG
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
// Stub log function used to work around for unused variable warnings when
|
|
Packit Service |
9def5d |
// building with STRIP_LOG > 0.
|
|
Packit Service |
9def5d |
static inline void RawLogStub__(int /* ignored */, ...) {
|
|
Packit Service |
9def5d |
}
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
// Helper function to implement RAW_LOG and RAW_VLOG
|
|
Packit Service |
9def5d |
// Logs format... at "severity" level, reporting it
|
|
Packit Service |
9def5d |
// as called from file:line.
|
|
Packit Service |
9def5d |
// This does not allocate memory or acquire locks.
|
|
Packit Service |
9def5d |
GOOGLE_GLOG_DLL_DECL void RawLog__(LogSeverity severity,
|
|
Packit Service |
9def5d |
const char* file,
|
|
Packit Service |
9def5d |
int line,
|
|
Packit Service |
9def5d |
const char* format, ...)
|
|
Packit Service |
9def5d |
;
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
// Hack to propagate time information into this module so that
|
|
Packit Service |
9def5d |
// this module does not have to directly call localtime_r(),
|
|
Packit Service |
9def5d |
// which could allocate memory.
|
|
Packit Service |
9def5d |
GOOGLE_GLOG_DLL_DECL void RawLog__SetLastTime(const struct tm& t, int usecs);
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
}
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
#endif // BASE_RAW_LOGGING_H_
|