summaryrefslogtreecommitdiff
path: root/src/glog/logging.h.in
diff options
context:
space:
mode:
author <shinichiro.hamaji@gmail.com>2008-12-19 15:20:40 +0000
committer <shinichiro.hamaji@gmail.com>2008-12-19 15:20:40 +0000
commitafd586a5d5c96a606773bd48422b892957419b59 (patch)
treeb807abf9182af1dd4d6832c45c3b4bdfd80a5813 /src/glog/logging.h.in
parentc54c735616b5dba9966c342b0e14e07833bbec7b (diff)
downloadglog-afd586a5d5c96a606773bd48422b892957419b59.tar.gz
glog-afd586a5d5c96a606773bd48422b892957419b59.tar.bz2
glog-afd586a5d5c96a606773bd48422b892957419b59.zip
Initial windows support. Now we don't have the stacktrace and several unittests.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@23 eb4d4688-79bd-11dd-afb4-1d65580434c0
Diffstat (limited to 'src/glog/logging.h.in')
-rw-r--r--src/glog/logging.h.in120
1 files changed, 76 insertions, 44 deletions
diff --git a/src/glog/logging.h.in b/src/glog/logging.h.in
index e982553..0949432 100644
--- a/src/glog/logging.h.in
+++ b/src/glog/logging.h.in
@@ -14,7 +14,9 @@
#include <string.h>
#include <time.h>
#include <string>
-#include <unistd.h>
+#if @ac_cv_have_unistd_h@
+# include <unistd.h>
+#endif
#ifdef __DEPRECATED
// Make GCC quiet.
# undef __DEPRECATED
@@ -25,6 +27,15 @@
#endif
#include <vector>
+// Annoying stuff for windows -- makes sure clients can import these functions
+#ifndef GOOGLE_GLOG_DLL_DECL
+# ifdef _WIN32
+# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
+# else
+# define GOOGLE_GLOG_DLL_DECL
+# endif
+#endif
+
// We care a lot about number of bits things take up. Unfortunately,
// systems define their bit-specific ints in a lot of different ways.
// We use our own way, and have a typedef to get there.
@@ -59,9 +70,9 @@ typedef int64_t int64;
typedef u_int64_t uint64;
#elif @ac_cv_have___uint16@ // the windows (vc7) format
typedef __int32 int32;
-typedef __uint32 uint32;
+typedef unsigned __int32 uint32;
typedef __int64 int64;
-typedef __uint64 uint64;
+typedef unsigned __int64 uint64;
#else
#error Do not know how to define a 32-bit integer quantity on your system
#endif
@@ -222,7 +233,7 @@ typedef __uint64 uint64;
#define MUST_UNDEF_GFLAGS_DECLARE_MACROS
#define DECLARE_VARIABLE(type, name, tn) \
namespace FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead { \
- extern type FLAGS_##name; \
+ extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name; \
} \
using FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead::FLAGS_##name
@@ -238,7 +249,7 @@ typedef __uint64 uint64;
// std::string, which doesn't play nicely with our FLAG__namespace hackery.
#define DECLARE_string(name) \
namespace FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead { \
- extern std::string FLAGS_##name; \
+ extern GOOGLE_GLOG_DLL_DECL std::string FLAGS_##name; \
} \
using FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead::FLAGS_##name
#endif
@@ -376,10 +387,10 @@ DECLARE_bool(alsologtostderr);
// Initialize google's logging library. You will see the program name
// specified by argv0 in log outputs.
-void InitGoogleLogging(const char* argv0);
+GOOGLE_GLOG_DLL_DECL void InitGoogleLogging(const char* argv0);
// Install a function which will be called after LOG(FATAL).
-void InstallFailureFunction(void (*fail_func)());
+GOOGLE_GLOG_DLL_DECL void InstallFailureFunction(void (*fail_func)());
class LogSink; // defined below
@@ -581,8 +592,8 @@ typedef std::string _Check_string;
// Helper functions for string comparisons.
// To avoid bloat, the definitions are in logging.cc.
#define DECLARE_CHECK_STROP_IMPL(func, expected) \
- std::string* Check##func##expected##Impl(const char* s1, const char* s2, \
- const char* names);
+ GOOGLE_GLOG_DLL_DECL std::string* Check##func##expected##Impl( \
+ const char* s1, const char* s2, const char* names);
DECLARE_CHECK_STROP_IMPL(strcmp, true)
DECLARE_CHECK_STROP_IMPL(strcmp, false)
DECLARE_CHECK_STROP_IMPL(strcasecmp, true)
@@ -833,7 +844,7 @@ enum PRIVATE_Counter {COUNTER};
// You shouldn't actually use LogMessage's constructor to log things,
// though. You should use the LOG() macro (and variants thereof)
// above.
-class LogMessage {
+class GOOGLE_GLOG_DLL_DECL LogMessage {
public:
enum {
// Passing kNoLogPrefix for the line number disables the
@@ -844,7 +855,19 @@ public:
kNoLogPrefix = -1
};
- class LogStream : public std::ostrstream {
+ // LogStream inherit from non-DLL-exported class (std::ostrstream)
+ // and VC++ produces a warning for this situation.
+ // However, MSDN says "C4275 can be ignored in Microsoft Visual C++
+ // 2005 if you are deriving from a type in the Standard C++ Library"
+ // http://msdn.microsoft.com/en-us/library/3tdb471s(VS.80).aspx
+ // Let's just ignore the warning.
+#ifdef _MSC_VER
+# pragma warning(disable: 4275)
+#endif
+ class GOOGLE_GLOG_DLL_DECL LogStream : public std::ostrstream {
+#ifdef _MSC_VER
+# pragma warning(default: 4275)
+#endif
public:
LogStream(char *buf, int len, int ctr)
: ostrstream(buf, len),
@@ -940,11 +963,9 @@ private:
// Counts of messages sent at each priority:
static int64 num_messages_[NUM_SEVERITIES]; // under log_mutex
- static LogMessageData fatal_message_data_;
-
// We keep the data in a separate struct so that each instance of
// LogMessage uses less stack space.
- struct LogMessageData {
+ struct GOOGLE_GLOG_DLL_DECL LogMessageData {
// ORDER DEPENDENCY: preserved_errno_ comes before buf_ comes before
// message_text_ comes before stream_
int preserved_errno_; // preserved errno
@@ -978,6 +999,8 @@ private:
void operator=(const LogMessageData&);
};
+ static LogMessageData fatal_message_data_;
+
LogMessageData* allocated_;
LogMessageData* data_;
@@ -990,7 +1013,7 @@ private:
// This class happens to be thread-hostile because all instances share
// a single data buffer, but since it can only be created just before
// the process dies, we don't worry so much.
-class LogMessageFatal : public LogMessage {
+class GOOGLE_GLOG_DLL_DECL LogMessageFatal : public LogMessage {
public:
LogMessageFatal(const char* file, int line);
LogMessageFatal(const char* file, int line, const CheckOpString& result);
@@ -1015,11 +1038,12 @@ T* CheckNotNull(const char *file, int line, const char *names, T* t) {
// Allow folks to put a counter in the LOG_EVERY_X()'ed messages. This
// only works if ostream is a LogStream. If the ostream is not a
// LogStream you'll get an assert saying as much at runtime.
-std::ostream& operator<<(std::ostream &os, const PRIVATE_Counter&);
+GOOGLE_GLOG_DLL_DECL std::ostream& operator<<(std::ostream &os,
+ const PRIVATE_Counter&);
// Derived class for PLOG*() above.
-class ErrnoLogMessage : public LogMessage {
+class GOOGLE_GLOG_DLL_DECL ErrnoLogMessage : public LogMessage {
public:
ErrnoLogMessage(const char* file, int line, LogSeverity severity, int ctr,
@@ -1038,7 +1062,7 @@ class ErrnoLogMessage : public LogMessage {
// logging macros. This avoids compiler warnings like "value computed
// is not used" and "statement has no effect".
-class LogMessageVoidify {
+class GOOGLE_GLOG_DLL_DECL LogMessageVoidify {
public:
LogMessageVoidify() { }
// This has to be an operator with a precedence lower than << but
@@ -1049,19 +1073,20 @@ class LogMessageVoidify {
// Flushes all log files that contains messages that are at least of
// the specified severity level. Thread-safe.
-void FlushLogFiles(LogSeverity min_severity);
+GOOGLE_GLOG_DLL_DECL void FlushLogFiles(LogSeverity min_severity);
// Flushes all log files that contains messages that are at least of
// the specified severity level. Thread-hostile because it ignores
// locking -- used for catastrophic failures.
-void FlushLogFilesUnsafe(LogSeverity min_severity);
+GOOGLE_GLOG_DLL_DECL void FlushLogFilesUnsafe(LogSeverity min_severity);
//
// Set the destination to which a particular severity level of log
// messages is sent. If base_filename is "", it means "don't log this
// severity". Thread-safe.
//
-void SetLogDestination(LogSeverity severity, const char* base_filename);
+GOOGLE_GLOG_DLL_DECL void SetLogDestination(LogSeverity severity,
+ const char* base_filename);
//
// Set the basename of the symlink to the latest log file at a given
@@ -1069,14 +1094,15 @@ void SetLogDestination(LogSeverity severity, const char* base_filename);
// you don't call this function, the symlink basename is the
// invocation name of the program. Thread-safe.
//
-void SetLogSymlink(LogSeverity severity, const char* symlink_basename);
+GOOGLE_GLOG_DLL_DECL void SetLogSymlink(LogSeverity severity,
+ const char* symlink_basename);
//
// Used to send logs to some other kind of destination
// Users should subclass LogSink and override send to do whatever they want.
// Implementations must be thread-safe because a shared instance will
// be called from whichever thread ran the LOG(XXX) line.
-class LogSink {
+class GOOGLE_GLOG_DLL_DECL LogSink {
public:
virtual ~LogSink();
@@ -1111,8 +1137,8 @@ class LogSink {
};
// Add or remove a LogSink as a consumer of logging data. Thread-safe.
-void AddLogSink(LogSink *destination);
-void RemoveLogSink(LogSink *destination);
+GOOGLE_GLOG_DLL_DECL void AddLogSink(LogSink *destination);
+GOOGLE_GLOG_DLL_DECL void RemoveLogSink(LogSink *destination);
//
// Specify an "extension" added to the filename specified via
@@ -1120,19 +1146,20 @@ void RemoveLogSink(LogSink *destination);
// often used to append the port we're listening on to the logfile
// name. Thread-safe.
//
-void SetLogFilenameExtension(const char* filename_extension);
+GOOGLE_GLOG_DLL_DECL void SetLogFilenameExtension(
+ const char* filename_extension);
//
// Make it so that all log messages of at least a particular severity
// are logged to stderr (in addition to logging to the usual log
// file(s)). Thread-safe.
//
-void SetStderrLogging(LogSeverity min_severity);
+GOOGLE_GLOG_DLL_DECL void SetStderrLogging(LogSeverity min_severity);
//
// Make it so that all log messages go only to stderr. Thread-safe.
//
-void LogToStderr();
+GOOGLE_GLOG_DLL_DECL void LogToStderr();
//
// Make it so that all log messages of at least a particular severity are
@@ -1140,13 +1167,15 @@ void LogToStderr();
// usual log file(s)). The list of addresses is just a string containing
// the email addresses to send to (separated by spaces, say). Thread-safe.
//
-void SetEmailLogging(LogSeverity min_severity, const char* addresses);
+GOOGLE_GLOG_DLL_DECL void SetEmailLogging(LogSeverity min_severity,
+ const char* addresses);
// A simple function that sends email. dest is a commma-separated
// list of addressess. Thread-safe.
-bool SendEmail(const char*dest, const char *subject, const char*body);
+GOOGLE_GLOG_DLL_DECL bool SendEmail(const char *dest,
+ const char *subject, const char *body);
-const std::vector<std::string>& GetLoggingDirectories();
+GOOGLE_GLOG_DLL_DECL const std::vector<std::string>& GetLoggingDirectories();
// For tests only: Clear the internal [cached] list of logging directories to
// force a refresh the next time GetLoggingDirectories is called.
@@ -1156,12 +1185,13 @@ void TestOnly_ClearLoggingDirectoriesList();
// Returns a set of existing temporary directories, which will be a
// subset of the directories returned by GetLogginDirectories().
// Thread-safe.
-void GetExistingTempDirectories(std::vector<std::string>* list);
+GOOGLE_GLOG_DLL_DECL void GetExistingTempDirectories(
+ std::vector<std::string>* list);
// Print any fatal message again -- useful to call from signal handler
// so that the last thing in the output is the fatal message.
// Thread-hostile, but a race is unlikely.
-void ReprintFatalMessage();
+GOOGLE_GLOG_DLL_DECL void ReprintFatalMessage();
// Truncate a log file that may be the append-only output of multiple
// processes and hence can't simply be renamed/reopened (typically a
@@ -1170,16 +1200,17 @@ void ReprintFatalMessage();
// be racing with other writers, this approach has the potential to
// lose very small amounts of data. For security, only follow symlinks
// if the path is /proc/self/fd/*
-void TruncateLogFile(const char *path, int64 limit, int64 keep);
+GOOGLE_GLOG_DLL_DECL void TruncateLogFile(const char *path,
+ int64 limit, int64 keep);
// Truncate stdout and stderr if they are over the value specified by
// --max_log_size; keep the final 1MB. This function has the same
// race condition as TruncateLogFile.
-void TruncateStdoutStderr();
+GOOGLE_GLOG_DLL_DECL void TruncateStdoutStderr();
// Return the string representation of the provided LogSeverity level.
// Thread-safe.
-const char* GetLogSeverityName(LogSeverity severity);
+GOOGLE_GLOG_DLL_DECL const char* GetLogSeverityName(LogSeverity severity);
// ---------------------------------------------------------------------
// Implementation details that are not useful to most clients
@@ -1194,7 +1225,7 @@ const char* GetLogSeverityName(LogSeverity severity);
namespace base {
-class Logger {
+class GOOGLE_GLOG_DLL_DECL Logger {
public:
virtual ~Logger();
@@ -1223,12 +1254,12 @@ class Logger {
// Get the logger for the specified severity level. The logger
// remains the property of the logging module and should not be
// deleted by the caller. Thread-safe.
-extern Logger* GetLogger(LogSeverity level);
+extern GOOGLE_GLOG_DLL_DECL Logger* GetLogger(LogSeverity level);
// Set the logger for the specified severity level. The logger
// becomes the property of the logging module and should not
// be deleted by the caller. Thread-safe.
-extern void SetLogger(LogSeverity level, Logger* logger);
+extern GOOGLE_GLOG_DLL_DECL void SetLogger(LogSeverity level, Logger* logger);
}
@@ -1242,11 +1273,11 @@ extern void SetLogger(LogSeverity level, Logger* logger);
// be set to an empty string, if this function failed. This means, in most
// cases, you do not need to check the error code and you can directly
// use the value of "buf". It will never have an undefined value.
-int posix_strerror_r(int err, char *buf, size_t len);
+GOOGLE_GLOG_DLL_DECL int posix_strerror_r(int err, char *buf, size_t len);
// A class for which we define operator<<, which does nothing.
-class NullStream : public LogMessage::LogStream {
+class GOOGLE_GLOG_DLL_DECL NullStream : public LogMessage::LogStream {
public:
// Initialize the LogStream so the messages can be written somewhere
// (they'll never be actually displayed). This will be needed if a
@@ -1272,7 +1303,7 @@ inline NullStream& operator<<(NullStream &str, const T &value) { return str; }
// Similar to NullStream, but aborts the program (without stack
// trace), like LogMessageFatal.
-class NullStreamFatal : public NullStream {
+class GOOGLE_GLOG_DLL_DECL NullStreamFatal : public NullStream {
public:
@ac_cv___attribute___noreturn@ ~NullStreamFatal() { _exit(1); }
};
@@ -1293,13 +1324,14 @@ class NullStreamFatal : public NullStream {
// to use the failure signal handler for all threads. The stack trace
// will be shown only for the thread that receives the signal. In other
// words, stack traces of other threads won't be shown.
-void InstallFailureSignalHandler();
+GOOGLE_GLOG_DLL_DECL void InstallFailureSignalHandler();
// Installs a function that is used for writing the failure dump. "data"
// is the pointer to the beginning of a message to be written, and "size"
// is the size of the message. You should not expect the data is
// terminated with '\0'.
-void InstallFailureWriter(void (*writer)(const char* data, int size));
+GOOGLE_GLOG_DLL_DECL void InstallFailureWriter(
+ void (*writer)(const char* data, int size));
@ac_google_end_namespace@