OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_LOG_UTILS_H_ | 5 #ifndef V8_LOG_UTILS_H_ |
6 #define V8_LOG_UTILS_H_ | 6 #define V8_LOG_UTILS_H_ |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 | 9 |
10 #include <cstdarg> | 10 #include <cstdarg> |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 void OpenStdout(); | 103 void OpenStdout(); |
104 | 104 |
105 // Opens file for logging. | 105 // Opens file for logging. |
106 void OpenFile(const char* name); | 106 void OpenFile(const char* name); |
107 | 107 |
108 // Opens a temporary file for logging. | 108 // Opens a temporary file for logging. |
109 void OpenTemporaryFile(); | 109 void OpenTemporaryFile(); |
110 | 110 |
111 // Implementation of writing to a log file. | 111 // Implementation of writing to a log file. |
112 int WriteToFile(const char* msg, int length) { | 112 int WriteToFile(const char* msg, int length) { |
113 DCHECK_NOT_NULL(output_handle_); | 113 DCHECK(output_handle_ != NULL); |
114 size_t rv = fwrite(msg, 1, length, output_handle_); | 114 size_t rv = fwrite(msg, 1, length, output_handle_); |
115 DCHECK_EQ(length, rv); | 115 DCHECK(static_cast<size_t>(length) == rv); |
116 USE(rv); | 116 USE(rv); |
117 fflush(output_handle_); | 117 fflush(output_handle_); |
118 return length; | 118 return length; |
119 } | 119 } |
120 | 120 |
121 // Whether logging is stopped (e.g. due to insufficient resources). | 121 // Whether logging is stopped (e.g. due to insufficient resources). |
122 bool is_stopped_; | 122 bool is_stopped_; |
123 | 123 |
124 // When logging is active output_handle_ is used to store a pointer to log | 124 // When logging is active output_handle_ is used to store a pointer to log |
125 // destination. mutex_ should be acquired before using output_handle_. | 125 // destination. mutex_ should be acquired before using output_handle_. |
(...skipping 10 matching lines...) Expand all Loading... |
136 Logger* logger_; | 136 Logger* logger_; |
137 | 137 |
138 friend class Logger; | 138 friend class Logger; |
139 }; | 139 }; |
140 | 140 |
141 | 141 |
142 } // namespace internal | 142 } // namespace internal |
143 } // namespace v8 | 143 } // namespace v8 |
144 | 144 |
145 #endif // V8_LOG_UTILS_H_ | 145 #endif // V8_LOG_UTILS_H_ |
OLD | NEW |