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

Side by Side Diff: chrome/common/logging_chrome.cc

Issue 12314090: Add utf_string_conversions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/json_value_serializer_unittest.cc ('k') | chrome/common/service_process_util.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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 // Need to include this before most other files because it defines 7 // Need to include this before most other files because it defines
8 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define 8 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define
9 // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the 9 // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the
10 // ViewMsgLog et al. functions. 10 // ViewMsgLog et al. functions.
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 376
377 chrome_logging_initialized_ = false; 377 chrome_logging_initialized_ = false;
378 chrome_logging_redirected_ = false; 378 chrome_logging_redirected_ = false;
379 } 379 }
380 380
381 base::FilePath GetLogFileName() { 381 base::FilePath GetLogFileName() {
382 std::string filename; 382 std::string filename;
383 scoped_ptr<base::Environment> env(base::Environment::Create()); 383 scoped_ptr<base::Environment> env(base::Environment::Create());
384 if (env->GetVar(env_vars::kLogFileName, &filename) && !filename.empty()) { 384 if (env->GetVar(env_vars::kLogFileName, &filename) && !filename.empty()) {
385 #if defined(OS_WIN) 385 #if defined(OS_WIN)
386 return base::FilePath(UTF8ToWide(filename)); 386 return base::FilePath(base::UTF8ToWide(filename));
387 #elif defined(OS_POSIX) 387 #elif defined(OS_POSIX)
388 return base::FilePath(filename); 388 return base::FilePath(filename);
389 #endif 389 #endif
390 } 390 }
391 391
392 const base::FilePath log_filename(FILE_PATH_LITERAL("chrome_debug.log")); 392 const base::FilePath log_filename(FILE_PATH_LITERAL("chrome_debug.log"));
393 base::FilePath log_path; 393 base::FilePath log_path;
394 394
395 if (PathService::Get(chrome::DIR_LOGS, &log_path)) { 395 if (PathService::Get(chrome::DIR_LOGS, &log_path)) {
396 log_path = log_path.Append(log_filename); 396 log_path = log_path.Append(log_filename);
(...skipping 18 matching lines...) Expand all
415 std::ifstream log_file; 415 std::ifstream log_file;
416 log_file.open(GetLogFileName().value().c_str()); 416 log_file.open(GetLogFileName().value().c_str());
417 if (!log_file.is_open()) 417 if (!log_file.is_open())
418 return 0; 418 return 0;
419 419
420 std::string utf8_line; 420 std::string utf8_line;
421 std::wstring wide_line; 421 std::wstring wide_line;
422 while (!log_file.eof()) { 422 while (!log_file.eof()) {
423 getline(log_file, utf8_line); 423 getline(log_file, utf8_line);
424 if (utf8_line.find(":FATAL:") != std::string::npos) { 424 if (utf8_line.find(":FATAL:") != std::string::npos) {
425 wide_line = UTF8ToWide(utf8_line); 425 wide_line = base::UTF8ToWide(utf8_line);
426 if (assertions) 426 if (assertions)
427 assertions->push_back(wide_line); 427 assertions->push_back(wide_line);
428 ++assertion_count; 428 ++assertion_count;
429 } 429 }
430 } 430 }
431 log_file.close(); 431 log_file.close();
432 432
433 return assertion_count; 433 return assertion_count;
434 } 434 }
435 435
436 base::FilePath GenerateTimestampedName(const base::FilePath& base_path, 436 base::FilePath GenerateTimestampedName(const base::FilePath& base_path,
437 base::Time timestamp) { 437 base::Time timestamp) {
438 base::Time::Exploded time_deets; 438 base::Time::Exploded time_deets;
439 timestamp.LocalExplode(&time_deets); 439 timestamp.LocalExplode(&time_deets);
440 std::string suffix = base::StringPrintf("_%02d%02d%02d-%02d%02d%02d", 440 std::string suffix = base::StringPrintf("_%02d%02d%02d-%02d%02d%02d",
441 time_deets.year, 441 time_deets.year,
442 time_deets.month, 442 time_deets.month,
443 time_deets.day_of_month, 443 time_deets.day_of_month,
444 time_deets.hour, 444 time_deets.hour,
445 time_deets.minute, 445 time_deets.minute,
446 time_deets.second); 446 time_deets.second);
447 return base_path.InsertBeforeExtensionASCII(suffix); 447 return base_path.InsertBeforeExtensionASCII(suffix);
448 } 448 }
449 449
450 } // namespace logging 450 } // namespace logging
OLDNEW
« no previous file with comments | « chrome/common/json_value_serializer_unittest.cc ('k') | chrome/common/service_process_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698