Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Side by Side Diff: third_party/WebKit/Source/wtf/DataLog.cpp

Issue 2386843002: reflow comments in wtf (Closed)
Patch Set: comments (heh!) Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/CurrentTime.h ('k') | third_party/WebKit/Source/wtf/DateMath.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 14 matching lines...) Expand all
25 25
26 #include "wtf/DataLog.h" 26 #include "wtf/DataLog.h"
27 27
28 #if OS(POSIX) 28 #if OS(POSIX)
29 #include <pthread.h> 29 #include <pthread.h>
30 #include <unistd.h> 30 #include <unistd.h>
31 #endif 31 #endif
32 32
33 #define DATA_LOG_TO_FILE 0 33 #define DATA_LOG_TO_FILE 0
34 34
35 // Uncomment to force logging to the given file regardless of what the environme nt variable says. Note that 35 // Uncomment to force logging to the given file regardless of what the
36 // we will append ".<pid>.txt" where <pid> is the PID. 36 // environment variable says. Note that we will append ".<pid>.txt" where <pid>
37 // is the PID.
37 38
38 // This path won't work on Windows, make sure to change to something like C:\\Us ers\\<more path>\\log.txt. 39 // This path won't work on Windows, make sure to change to something like
40 // C:\\Users\\<more path>\\log.txt.
39 #define DATA_LOG_FILENAME "/tmp/WTFLog" 41 #define DATA_LOG_FILENAME "/tmp/WTFLog"
40 42
41 namespace WTF { 43 namespace WTF {
42 44
43 #if OS(POSIX) 45 #if OS(POSIX)
44 static pthread_once_t initializeLogFileOnceKey = PTHREAD_ONCE_INIT; 46 static pthread_once_t initializeLogFileOnceKey = PTHREAD_ONCE_INIT;
45 #endif 47 #endif
46 48
47 static FilePrintStream* file; 49 static FilePrintStream* file;
48 50
(...skipping 12 matching lines...) Expand all
61 if (filename) { 63 if (filename) {
62 file = FilePrintStream::open(actualFilename, "w").release(); 64 file = FilePrintStream::open(actualFilename, "w").release();
63 if (!file) 65 if (!file)
64 fprintf(stderr, "Warning: Could not open log file %s for writing.\n", 66 fprintf(stderr, "Warning: Could not open log file %s for writing.\n",
65 actualFilename); 67 actualFilename);
66 } 68 }
67 #endif // DATA_LOG_TO_FILE 69 #endif // DATA_LOG_TO_FILE
68 if (!file) 70 if (!file)
69 file = new FilePrintStream(stderr, FilePrintStream::Borrow); 71 file = new FilePrintStream(stderr, FilePrintStream::Borrow);
70 72
71 setvbuf( 73 // Prefer unbuffered output, so that we get a full log upon crash or
72 file->file(), 0, _IONBF, 74 // deadlock.
73 0); // Prefer unbuffered output, so that we get a full log upon crash or deadlock. 75 setvbuf(file->file(), 0, _IONBF, 0);
74 } 76 }
75 77
76 static void initializeLogFile() { 78 static void initializeLogFile() {
77 #if OS(POSIX) 79 #if OS(POSIX)
78 pthread_once(&initializeLogFileOnceKey, initializeLogFileOnce); 80 pthread_once(&initializeLogFileOnceKey, initializeLogFileOnce);
79 #else 81 #else
80 if (!file) 82 if (!file)
81 initializeLogFileOnce(); 83 initializeLogFileOnce();
82 #endif 84 #endif
83 } 85 }
84 86
85 FilePrintStream& dataFile() { 87 FilePrintStream& dataFile() {
86 initializeLogFile(); 88 initializeLogFile();
87 return *file; 89 return *file;
88 } 90 }
89 91
90 void dataLogFV(const char* format, va_list argList) { 92 void dataLogFV(const char* format, va_list argList) {
91 dataFile().vprintf(format, argList); 93 dataFile().vprintf(format, argList);
92 } 94 }
93 95
94 void dataLogF(const char* format, ...) { 96 void dataLogF(const char* format, ...) {
95 va_list argList; 97 va_list argList;
96 va_start(argList, format); 98 va_start(argList, format);
97 dataLogFV(format, argList); 99 dataLogFV(format, argList);
98 va_end(argList); 100 va_end(argList);
99 } 101 }
100 102
101 } // namespace WTF 103 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/CurrentTime.h ('k') | third_party/WebKit/Source/wtf/DateMath.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698