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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 190 |
191 #ifdef ERROR | 191 #ifdef ERROR |
192 #undef ERROR // may conflict with ERROR macro on windows | 192 #undef ERROR // may conflict with ERROR macro on windows |
193 #endif | 193 #endif |
194 enum LogSeverity {INFO = -1, WARNING = -2, ERROR = -3, FATAL = -4}; | 194 enum LogSeverity {INFO = -1, WARNING = -2, ERROR = -3, FATAL = -4}; |
195 | 195 |
196 // NOTE: we add a newline to the end of the output if it's not there already | 196 // NOTE: we add a newline to the end of the output if it's not there already |
197 inline void LogPrintf(int severity, const char* pat, va_list ap) { | 197 inline void LogPrintf(int severity, const char* pat, va_list ap) { |
198 // We write directly to the stderr file descriptor and avoid FILE | 198 // We write directly to the stderr file descriptor and avoid FILE |
199 // buffering because that may invoke malloc() | 199 // buffering because that may invoke malloc() |
200 char buf[600]; | 200 char buf[1600]; |
201 perftools_vsnprintf(buf, sizeof(buf)-1, pat, ap); | 201 perftools_vsnprintf(buf, sizeof(buf)-1, pat, ap); |
202 if (buf[0] != '\0' && buf[strlen(buf)-1] != '\n') { | 202 if (buf[0] != '\0' && buf[strlen(buf)-1] != '\n') { |
203 assert(strlen(buf)+1 < sizeof(buf)); | 203 assert(strlen(buf)+1 < sizeof(buf)); |
204 strcat(buf, "\n"); | 204 strcat(buf, "\n"); |
205 } | 205 } |
206 WRITE_TO_STDERR(buf, strlen(buf)); | 206 WRITE_TO_STDERR(buf, strlen(buf)); |
207 if ((severity) == FATAL) | 207 if ((severity) == FATAL) |
208 abort(); // LOG(FATAL) indicates a big problem, so don't run atexit() calls | 208 abort(); // LOG(FATAL) indicates a big problem, so don't run atexit() calls |
209 } | 209 } |
210 | 210 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 #else | 249 #else |
250 typedef int RawFD; | 250 typedef int RawFD; |
251 const RawFD kIllegalRawFD = -1; // what open returns if it fails | 251 const RawFD kIllegalRawFD = -1; // what open returns if it fails |
252 #endif // defined(_WIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__) | 252 #endif // defined(_WIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__) |
253 | 253 |
254 RawFD RawOpenForWriting(const char* filename); // uses default permissions | 254 RawFD RawOpenForWriting(const char* filename); // uses default permissions |
255 void RawWrite(RawFD fd, const char* buf, size_t len); | 255 void RawWrite(RawFD fd, const char* buf, size_t len); |
256 void RawClose(RawFD fd); | 256 void RawClose(RawFD fd); |
257 | 257 |
258 #endif // _LOGGING_H_ | 258 #endif // _LOGGING_H_ |
OLD | NEW |