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

Side by Side Diff: runtime/bin/platform_win.cc

Issue 11312242: Revised CL for customisable logging (replacing printfs). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/log.h"
Ivan Posva 2012/11/17 01:13:42 Please move this under "bin/platform.h".
gram 2012/11/19 17:38:56 Done.
5 #include "bin/platform.h" 6 #include "bin/platform.h"
6 #include "bin/socket.h" 7 #include "bin/socket.h"
7 8
8 bool Platform::Initialize() { 9 bool Platform::Initialize() {
9 // Nothing to do on Windows. 10 // Nothing to do on Windows.
10 return true; 11 return true;
11 } 12 }
12 13
13 14
14 int Platform::NumberOfProcessors() { 15 int Platform::NumberOfProcessors() {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 DWORD message_size = 67 DWORD message_size =
67 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 68 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
68 NULL, 69 NULL,
69 error_code, 70 error_code,
70 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 71 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
71 error, 72 error,
72 kBufferSize, 73 kBufferSize,
73 NULL); 74 NULL);
74 if (message_size == 0) { 75 if (message_size == 0) {
75 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { 76 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
76 fprintf(stderr, "FormatMessage failed %d\n", GetLastError()); 77 Log::PrintErr("FormatMessage failed %d\n", GetLastError());
77 } 78 }
78 snprintf(error, kBufferSize, "OS Error %d", error_code); 79 snprintf(error, kBufferSize, "OS Error %d", error_code);
79 } 80 }
80 // Strip out \r\n at the end of the generated message and ensure 81 // Strip out \r\n at the end of the generated message and ensure
81 // null termination. 82 // null termination.
82 if (message_size > 2 && 83 if (message_size > 2 &&
83 error[message_size - 2] == '\r' && 84 error[message_size - 2] == '\r' &&
84 error[message_size - 1] == '\n') { 85 error[message_size - 1] == '\n') {
85 error[message_size - 2] = '\0'; 86 error[message_size - 2] = '\0';
86 } else { 87 } else {
87 error[kBufferSize - 1] = '\0'; 88 error[kBufferSize - 1] = '\0';
88 } 89 }
89 return error; 90 return error;
90 } 91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698