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

Side by Side Diff: base/logging.cc

Issue 2083463003: Revert of Add chrome_crash_reporter_client_win.cc to the source file list for chrome_elf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/files/file_path.cc ('k') | base/message_loop/message_pump_win.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 // 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 #include <limits.h> 7 #include <limits.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 12
13 #if defined(OS_WIN) 13 #if defined(OS_WIN)
14 #include <io.h> 14 #include <io.h>
15 #include <windows.h> 15 #include <windows.h>
16 #include "base/files/file_path.h"
17 #include "base/files/file_util.h"
16 typedef HANDLE FileHandle; 18 typedef HANDLE FileHandle;
17 typedef HANDLE MutexHandle; 19 typedef HANDLE MutexHandle;
18 // Windows warns on using write(). It prefers _write(). 20 // Windows warns on using write(). It prefers _write().
19 #define write(fd, buf, count) _write(fd, buf, static_cast<unsigned int>(count)) 21 #define write(fd, buf, count) _write(fd, buf, static_cast<unsigned int>(count))
20 // Windows doesn't define STDERR_FILENO. Define it here. 22 // Windows doesn't define STDERR_FILENO. Define it here.
21 #define STDERR_FILENO 2 23 #define STDERR_FILENO 2
22 #elif defined(OS_MACOSX) 24 #elif defined(OS_MACOSX)
23 #include <asl.h> 25 #include <asl.h>
24 #include <CoreFoundation/CoreFoundation.h> 26 #include <CoreFoundation/CoreFoundation.h>
25 #include <mach/mach.h> 27 #include <mach/mach.h>
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 if ((g_logging_destination & LOG_TO_FILE) != 0) { 282 if ((g_logging_destination & LOG_TO_FILE) != 0) {
281 #if defined(OS_WIN) 283 #if defined(OS_WIN)
282 // The FILE_APPEND_DATA access mask ensures that the file is atomically 284 // The FILE_APPEND_DATA access mask ensures that the file is atomically
283 // appended to across accesses from multiple threads. 285 // appended to across accesses from multiple threads.
284 // https://msdn.microsoft.com/en-us/library/windows/desktop/aa364399(v=vs.85 ).aspx 286 // https://msdn.microsoft.com/en-us/library/windows/desktop/aa364399(v=vs.85 ).aspx
285 // https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85 ).aspx 287 // https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85 ).aspx
286 g_log_file = CreateFile(g_log_file_name->c_str(), FILE_APPEND_DATA, 288 g_log_file = CreateFile(g_log_file_name->c_str(), FILE_APPEND_DATA,
287 FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, 289 FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
288 OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); 290 OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
289 if (g_log_file == INVALID_HANDLE_VALUE || g_log_file == nullptr) { 291 if (g_log_file == INVALID_HANDLE_VALUE || g_log_file == nullptr) {
290 // We are intentionally not using FilePath or FileUtil here to reduce the
291 // dependencies of the logging implementation. For e.g. FilePath and
292 // FileUtil depend on shell32 and user32.dll. This is not acceptable for
293 // some consumers of base logging like chrome_elf, etc.
294 // Please don't change the code below to use FilePath.
295 // try the current directory 292 // try the current directory
296 wchar_t system_buffer[MAX_PATH]; 293 base::FilePath file_path;
297 system_buffer[0] = 0; 294 if (!base::GetCurrentDirectory(&file_path))
298 DWORD len = ::GetCurrentDirectory(arraysize(system_buffer),
299 system_buffer);
300 if (len == 0 || len > arraysize(system_buffer))
301 return false; 295 return false;
302 296
303 *g_log_file_name = system_buffer; 297 *g_log_file_name = file_path.Append(
304 // Append a trailing backslash if needed. 298 FILE_PATH_LITERAL("debug.log")).value();
305 if (g_log_file_name->back() != L'\\')
306 *g_log_file_name += L"\\";
307 *g_log_file_name += L"debug.log";
308 299
309 g_log_file = CreateFile(g_log_file_name->c_str(), FILE_APPEND_DATA, 300 g_log_file = CreateFile(g_log_file_name->c_str(), FILE_APPEND_DATA,
310 FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, 301 FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
311 OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); 302 OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
312 if (g_log_file == INVALID_HANDLE_VALUE || g_log_file == nullptr) { 303 if (g_log_file == INVALID_HANDLE_VALUE || g_log_file == nullptr) {
313 g_log_file = nullptr; 304 g_log_file = nullptr;
314 return false; 305 return false;
315 } 306 }
316 } 307 }
317 #elif defined(OS_POSIX) 308 #elif defined(OS_POSIX)
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { 912 BASE_EXPORT void LogErrorNotReached(const char* file, int line) {
922 LogMessage(file, line, LOG_ERROR).stream() 913 LogMessage(file, line, LOG_ERROR).stream()
923 << "NOTREACHED() hit."; 914 << "NOTREACHED() hit.";
924 } 915 }
925 916
926 } // namespace logging 917 } // namespace logging
927 918
928 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { 919 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) {
929 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); 920 return out << (wstr ? base::WideToUTF8(wstr) : std::string());
930 } 921 }
OLDNEW
« no previous file with comments | « base/files/file_path.cc ('k') | base/message_loop/message_pump_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698