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

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

Issue 1436153002: Apply clang-format with Chromium-style without column limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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/DataLog.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 29 matching lines...) Expand all
40 #define DATA_LOG_FILENAME "/tmp/WTFLog" 40 #define DATA_LOG_FILENAME "/tmp/WTFLog"
41 41
42 namespace WTF { 42 namespace WTF {
43 43
44 #if OS(POSIX) 44 #if OS(POSIX)
45 static pthread_once_t initializeLogFileOnceKey = PTHREAD_ONCE_INIT; 45 static pthread_once_t initializeLogFileOnceKey = PTHREAD_ONCE_INIT;
46 #endif 46 #endif
47 47
48 static FilePrintStream* file; 48 static FilePrintStream* file;
49 49
50 static void initializeLogFileOnce() 50 static void initializeLogFileOnce() {
51 {
52 #if DATA_LOG_TO_FILE 51 #if DATA_LOG_TO_FILE
53 #ifdef DATA_LOG_FILENAME 52 #ifdef DATA_LOG_FILENAME
54 const char* filename = DATA_LOG_FILENAME; 53 const char* filename = DATA_LOG_FILENAME;
55 #else 54 #else
56 const char* filename = getenv("WTF_DATA_LOG_FILENAME"); 55 const char* filename = getenv("WTF_DATA_LOG_FILENAME");
57 #endif 56 #endif
58 char actualFilename[1024]; 57 char actualFilename[1024];
59 58
60 snprintf(actualFilename, sizeof(actualFilename), "%s.%d.txt", filename, getp id()); 59 snprintf(actualFilename, sizeof(actualFilename), "%s.%d.txt", filename, getpid ());
61 60
62 if (filename) { 61 if (filename) {
63 file = FilePrintStream::open(actualFilename, "w").leakPtr(); 62 file = FilePrintStream::open(actualFilename, "w").leakPtr();
64 if (!file)
65 fprintf(stderr, "Warning: Could not open log file %s for writing.\n" , actualFilename);
66 }
67 #endif // DATA_LOG_TO_FILE
68 if (!file) 63 if (!file)
69 file = new FilePrintStream(stderr, FilePrintStream::Borrow); 64 fprintf(stderr, "Warning: Could not open log file %s for writing.\n", actu alFilename);
65 }
66 #endif // DATA_LOG_TO_FILE
67 if (!file)
68 file = new FilePrintStream(stderr, FilePrintStream::Borrow);
70 69
71 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.
72 } 71 }
73 72
74 static void initializeLogFile() 73 static void initializeLogFile() {
75 {
76 #if OS(POSIX) 74 #if OS(POSIX)
77 pthread_once(&initializeLogFileOnceKey, initializeLogFileOnce); 75 pthread_once(&initializeLogFileOnceKey, initializeLogFileOnce);
78 #else 76 #else
79 if (!file) 77 if (!file)
80 initializeLogFileOnce(); 78 initializeLogFileOnce();
81 #endif 79 #endif
82 } 80 }
83 81
84 FilePrintStream& dataFile() 82 FilePrintStream& dataFile() {
85 { 83 initializeLogFile();
86 initializeLogFile(); 84 return *file;
87 return *file;
88 } 85 }
89 86
90 void dataLogFV(const char* format, va_list argList) 87 void dataLogFV(const char* format, va_list argList) {
91 { 88 dataFile().vprintf(format, argList);
92 dataFile().vprintf(format, argList);
93 } 89 }
94 90
95 void dataLogF(const char* format, ...) 91 void dataLogF(const char* format, ...) {
96 { 92 va_list argList;
97 va_list argList; 93 va_start(argList, format);
98 va_start(argList, format); 94 dataLogFV(format, argList);
99 dataLogFV(format, argList); 95 va_end(argList);
100 va_end(argList);
101 } 96 }
102 97
103 void dataLogFString(const char* str) 98 void dataLogFString(const char* str) {
104 { 99 dataFile().printf("%s", str);
105 dataFile().printf("%s", str);
106 } 100 }
107 101
108 } // namespace WTF 102 } // namespace WTF
109
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/DataLog.h ('k') | third_party/WebKit/Source/wtf/DateMath.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698