OLD | NEW |
1 // Copyright (c) 2005, Google Inc. | 1 // Copyright (c) 2005, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 #ifdef ERROR | 172 #ifdef ERROR |
173 #undef ERROR // may conflict with ERROR macro on windows | 173 #undef ERROR // may conflict with ERROR macro on windows |
174 #endif | 174 #endif |
175 enum LogSeverity {INFO = -1, WARNING = -2, ERROR = -3, FATAL = -4}; | 175 enum LogSeverity {INFO = -1, WARNING = -2, ERROR = -3, FATAL = -4}; |
176 | 176 |
177 // NOTE: we add a newline to the end of the output if it's not there already | 177 // NOTE: we add a newline to the end of the output if it's not there already |
178 inline void LogPrintf(int severity, const char* pat, va_list ap) { | 178 inline void LogPrintf(int severity, const char* pat, va_list ap) { |
179 // We write directly to the stderr file descriptor and avoid FILE | 179 // We write directly to the stderr file descriptor and avoid FILE |
180 // buffering because that may invoke malloc() | 180 // buffering because that may invoke malloc() |
181 char buf[600]; | 181 char buf[1600]; |
182 vsnprintf(buf, sizeof(buf)-1, pat, ap); | 182 vsnprintf(buf, sizeof(buf)-1, pat, ap); |
183 if (buf[0] != '\0' && buf[strlen(buf)-1] != '\n') { | 183 if (buf[0] != '\0' && buf[strlen(buf)-1] != '\n') { |
184 assert(strlen(buf)+1 < sizeof(buf)); | 184 assert(strlen(buf)+1 < sizeof(buf)); |
185 strcat(buf, "\n"); | 185 strcat(buf, "\n"); |
186 } | 186 } |
187 WRITE_TO_STDERR(buf, strlen(buf)); | 187 WRITE_TO_STDERR(buf, strlen(buf)); |
188 if ((severity) == FATAL) | 188 if ((severity) == FATAL) |
189 abort(); // LOG(FATAL) indicates a big problem, so don't run atexit() calls | 189 abort(); // LOG(FATAL) indicates a big problem, so don't run atexit() calls |
190 } | 190 } |
191 | 191 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 #else | 227 #else |
228 typedef int RawFD; | 228 typedef int RawFD; |
229 const RawFD kIllegalRawFD = -1; // what open returns if it fails | 229 const RawFD kIllegalRawFD = -1; // what open returns if it fails |
230 #endif // defined(_WIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__) | 230 #endif // defined(_WIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__) |
231 | 231 |
232 RawFD RawOpenForWriting(const char* filename); // uses default permissions | 232 RawFD RawOpenForWriting(const char* filename); // uses default permissions |
233 void RawWrite(RawFD fd, const char* buf, size_t len); | 233 void RawWrite(RawFD fd, const char* buf, size_t len); |
234 void RawClose(RawFD fd); | 234 void RawClose(RawFD fd); |
235 | 235 |
236 #endif // _LOGGING_H_ | 236 #endif // _LOGGING_H_ |
OLD | NEW |