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

Side by Side Diff: base/logging.cc

Issue 13866034: Pepper: Add VLOG support for NaCl plugins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 7 years, 8 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 | « base/base_untrusted.gyp ('k') | chrome/browser/nacl_host/nacl_process_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium 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 #include "base/logging.h" 5 #include "base/logging.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <io.h> 8 #include <io.h>
9 #include <windows.h> 9 #include <windows.h>
10 typedef HANDLE FileHandle; 10 typedef HANDLE FileHandle;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 #if defined(OS_WIN) 156 #if defined(OS_WIN)
157 CloseHandle(log); 157 CloseHandle(log);
158 #else 158 #else
159 fclose(log); 159 fclose(log);
160 #endif 160 #endif
161 } 161 }
162 162
163 void DeleteFilePath(const PathString& log_name) { 163 void DeleteFilePath(const PathString& log_name) {
164 #if defined(OS_WIN) 164 #if defined(OS_WIN)
165 DeleteFile(log_name.c_str()); 165 DeleteFile(log_name.c_str());
166 #elif defined (OS_NACL)
167 // Do nothing; unlink() isn't supported on NaCl.
166 #else 168 #else
167 unlink(log_name.c_str()); 169 unlink(log_name.c_str());
168 #endif 170 #endif
169 } 171 }
170 172
171 PathString GetDefaultLogFile() { 173 PathString GetDefaultLogFile() {
172 #if defined(OS_WIN) 174 #if defined(OS_WIN)
173 // On Windows we use the same path as the exe. 175 // On Windows we use the same path as the exe.
174 wchar_t module_name[MAX_PATH]; 176 wchar_t module_name[MAX_PATH];
175 GetModuleFileName(NULL, module_name, MAX_PATH); 177 GetModuleFileName(NULL, module_name, MAX_PATH);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 343 }
342 344
343 } // namespace 345 } // namespace
344 346
345 347
346 bool BaseInitLoggingImpl(const PathChar* new_log_file, 348 bool BaseInitLoggingImpl(const PathChar* new_log_file,
347 LoggingDestination logging_dest, 349 LoggingDestination logging_dest,
348 LogLockingState lock_log, 350 LogLockingState lock_log,
349 OldFileDeletionState delete_old, 351 OldFileDeletionState delete_old,
350 DcheckState dcheck_state) { 352 DcheckState dcheck_state) {
353 #if defined(OS_NACL)
354 CHECK(logging_dest == LOG_NONE ||
355 logging_dest == LOG_ONLY_TO_SYSTEM_DEBUG_LOG);
356 #endif
351 g_dcheck_state = dcheck_state; 357 g_dcheck_state = dcheck_state;
352 // TODO(bbudge) Hook this up to NaCl logging.
353 #if !defined(OS_NACL)
354 CommandLine* command_line = CommandLine::ForCurrentProcess(); 358 CommandLine* command_line = CommandLine::ForCurrentProcess();
355 // Don't bother initializing g_vlog_info unless we use one of the 359 // Don't bother initializing g_vlog_info unless we use one of the
356 // vlog switches. 360 // vlog switches.
357 if (command_line->HasSwitch(switches::kV) || 361 if (command_line->HasSwitch(switches::kV) ||
358 command_line->HasSwitch(switches::kVModule)) { 362 command_line->HasSwitch(switches::kVModule)) {
359 // NOTE: If g_vlog_info has already been initialized, it might be in use 363 // NOTE: If g_vlog_info has already been initialized, it might be in use
360 // by another thread. Don't delete the old VLogInfo, just create a second 364 // by another thread. Don't delete the old VLogInfo, just create a second
361 // one. We keep track of both to avoid memory leak warnings. 365 // one. We keep track of both to avoid memory leak warnings.
362 CHECK(!g_vlog_info_prev); 366 CHECK(!g_vlog_info_prev);
363 g_vlog_info_prev = g_vlog_info; 367 g_vlog_info_prev = g_vlog_info;
(...skipping 22 matching lines...) Expand all
386 logging_destination == LOG_ONLY_TO_SYSTEM_DEBUG_LOG) 390 logging_destination == LOG_ONLY_TO_SYSTEM_DEBUG_LOG)
387 return true; 391 return true;
388 392
389 if (!log_file_name) 393 if (!log_file_name)
390 log_file_name = new PathString(); 394 log_file_name = new PathString();
391 *log_file_name = new_log_file; 395 *log_file_name = new_log_file;
392 if (delete_old == DELETE_OLD_LOG_FILE) 396 if (delete_old == DELETE_OLD_LOG_FILE)
393 DeleteFilePath(*log_file_name); 397 DeleteFilePath(*log_file_name);
394 398
395 return InitializeLogFileHandle(); 399 return InitializeLogFileHandle();
396 #else
397 (void) g_vlog_info_prev;
398 return true;
399 #endif // !defined(OS_NACL)
400 } 400 }
401 401
402 void SetMinLogLevel(int level) { 402 void SetMinLogLevel(int level) {
403 min_log_level = std::min(LOG_ERROR_REPORT, level); 403 min_log_level = std::min(LOG_ERROR_REPORT, level);
404 } 404 }
405 405
406 int GetMinLogLevel() { 406 int GetMinLogLevel() {
407 return min_log_level; 407 return min_log_level;
408 } 408 }
409 409
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 return *log_file_name; 860 return *log_file_name;
861 return std::wstring(); 861 return std::wstring();
862 } 862 }
863 #endif 863 #endif
864 864
865 } // namespace logging 865 } // namespace logging
866 866
867 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { 867 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) {
868 return out << WideToUTF8(std::wstring(wstr)); 868 return out << WideToUTF8(std::wstring(wstr));
869 } 869 }
OLDNEW
« no previous file with comments | « base/base_untrusted.gyp ('k') | chrome/browser/nacl_host/nacl_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698