| 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 "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 void OpenStdout(); | 96 void OpenStdout(); |
| 97 | 97 |
| 98 // Opens file for logging. | 98 // Opens file for logging. |
| 99 void OpenFile(const char* name); | 99 void OpenFile(const char* name); |
| 100 | 100 |
| 101 // Opens a temporary file for logging. | 101 // Opens a temporary file for logging. |
| 102 void OpenTemporaryFile(); | 102 void OpenTemporaryFile(); |
| 103 | 103 |
| 104 // Implementation of writing to a log file. | 104 // Implementation of writing to a log file. |
| 105 int WriteToFile(const char* msg, int length) { | 105 int WriteToFile(const char* msg, int length) { |
| 106 ASSERT(output_handle_ != NULL); | 106 DCHECK(output_handle_ != NULL); |
| 107 size_t rv = fwrite(msg, 1, length, output_handle_); | 107 size_t rv = fwrite(msg, 1, length, output_handle_); |
| 108 ASSERT(static_cast<size_t>(length) == rv); | 108 DCHECK(static_cast<size_t>(length) == rv); |
| 109 USE(rv); | 109 USE(rv); |
| 110 fflush(output_handle_); | 110 fflush(output_handle_); |
| 111 return length; | 111 return length; |
| 112 } | 112 } |
| 113 | 113 |
| 114 // Whether logging is stopped (e.g. due to insufficient resources). | 114 // Whether logging is stopped (e.g. due to insufficient resources). |
| 115 bool is_stopped_; | 115 bool is_stopped_; |
| 116 | 116 |
| 117 // When logging is active output_handle_ is used to store a pointer to log | 117 // When logging is active output_handle_ is used to store a pointer to log |
| 118 // destination. mutex_ should be acquired before using output_handle_. | 118 // destination. mutex_ should be acquired before using output_handle_. |
| 119 FILE* output_handle_; | 119 FILE* output_handle_; |
| 120 | 120 |
| 121 // mutex_ is a Mutex used for enforcing exclusive | 121 // mutex_ is a Mutex used for enforcing exclusive |
| 122 // access to the formatting buffer and the log file or log memory buffer. | 122 // access to the formatting buffer and the log file or log memory buffer. |
| 123 base::Mutex mutex_; | 123 base::Mutex mutex_; |
| 124 | 124 |
| 125 // Buffer used for formatting log messages. This is a singleton buffer and | 125 // Buffer used for formatting log messages. This is a singleton buffer and |
| 126 // mutex_ should be acquired before using it. | 126 // mutex_ should be acquired before using it. |
| 127 char* message_buffer_; | 127 char* message_buffer_; |
| 128 | 128 |
| 129 Logger* logger_; | 129 Logger* logger_; |
| 130 | 130 |
| 131 friend class Logger; | 131 friend class Logger; |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 | 134 |
| 135 } } // namespace v8::internal | 135 } } // namespace v8::internal |
| 136 | 136 |
| 137 #endif // V8_LOG_UTILS_H_ | 137 #endif // V8_LOG_UTILS_H_ |
| OLD | NEW |