OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #ifdef DATA_LOG_FILENAME | 52 #ifdef DATA_LOG_FILENAME |
53 const char* filename = DATA_LOG_FILENAME; | 53 const char* filename = DATA_LOG_FILENAME; |
54 #else | 54 #else |
55 const char* filename = getenv("WTF_DATA_LOG_FILENAME"); | 55 const char* filename = getenv("WTF_DATA_LOG_FILENAME"); |
56 #endif | 56 #endif |
57 char actualFilename[1024]; | 57 char actualFilename[1024]; |
58 | 58 |
59 snprintf(actualFilename, sizeof(actualFilename), "%s.%d.txt", filename, getp
id()); | 59 snprintf(actualFilename, sizeof(actualFilename), "%s.%d.txt", filename, getp
id()); |
60 | 60 |
61 if (filename) { | 61 if (filename) { |
62 file = FilePrintStream::open(actualFilename, "w").leakPtr(); | 62 file = FilePrintStream::open(actualFilename, "w").release(); |
63 if (!file) | 63 if (!file) |
64 fprintf(stderr, "Warning: Could not open log file %s for writing.\n"
, actualFilename); | 64 fprintf(stderr, "Warning: Could not open log file %s for writing.\n"
, actualFilename); |
65 } | 65 } |
66 #endif // DATA_LOG_TO_FILE | 66 #endif // DATA_LOG_TO_FILE |
67 if (!file) | 67 if (!file) |
68 file = new FilePrintStream(stderr, FilePrintStream::Borrow); | 68 file = new FilePrintStream(stderr, FilePrintStream::Borrow); |
69 | 69 |
70 setvbuf(file->file(), 0, _IONBF, 0); // Prefer unbuffered output, so that we
get a full log upon crash or deadlock. | 70 setvbuf(file->file(), 0, _IONBF, 0); // Prefer unbuffered output, so that we
get a full log upon crash or deadlock. |
71 } | 71 } |
72 | 72 |
(...skipping 21 matching lines...) Expand all Loading... |
94 void dataLogF(const char* format, ...) | 94 void dataLogF(const char* format, ...) |
95 { | 95 { |
96 va_list argList; | 96 va_list argList; |
97 va_start(argList, format); | 97 va_start(argList, format); |
98 dataLogFV(format, argList); | 98 dataLogFV(format, argList); |
99 va_end(argList); | 99 va_end(argList); |
100 } | 100 } |
101 | 101 |
102 } // namespace WTF | 102 } // namespace WTF |
103 | 103 |
OLD | NEW |