23 #ifdef XAPIAN_DEBUG_LOG 30 #include <sys/types.h> 41 DebugLogger xapian_debuglogger_;
43 DebugLogger::~DebugLogger()
49 DebugLogger::initialise_categories_mask()
52 const char* f = getenv(
"XAPIAN_DEBUG_LOG");
55 if (f[0] ==
'-' && f[1] ==
'\0') {
64 if (pid.empty()) pid =
str(getpid());
68 }
else if (f[1] ==
'!') {
87 flags |= O_CREAT|O_WRONLY|O_APPEND|
O_CLOEXEC;
88 fd =
open(fnm.c_str(), flags, 0644);
102 const char* v = getenv(
"XAPIAN_DEBUG_FLAGS");
104 bool toggle = (*v ==
'-');
109 if (ch > 0 && ch <= 26) categories_mask |= 1ul << ch;
111 if (toggle) categories_mask ^= 0xffffffff;
119 DebugLogger::log_line(debuglog_categories
category,
const string& msg)
125 int saved_errno = errno;
128 line.reserve(9 + indent_level + msg.size());
129 line = char(category) +
'@';
131 line +=
str(getpid());
132 line.append(indent_level + 1,
' ');
136 const char* p = line.data();
137 size_t to_do = line.size();
139 ssize_t n = write(fd, p, to_do);
142 if (errno == EINTR)
continue;
160 #endif // XAPIAN_DEBUG_LOG
category
Each Unicode character is in exactly one of these categories.
Convert errno value to std::string, thread-safe if possible.
WritableDatabase open()
Construct a WritableDatabase object for a new, empty InMemory database.
Convert types to std::string.
include <sys/stat.h> with portability enhancements
void errno_to_string(int e, string &s)
string str(int value)
Convert int to std::string.
<unistd.h>, but with compat.
include <fcntl.h>, but working around broken platforms.