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

Side by Side Diff: runtime/bin/utils_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
« no previous file with comments | « runtime/bin/socket_win.cc ('k') | no next file » | 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 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 <errno.h> 5 #include <errno.h>
6 6
7 #include "bin/utils.h" 7 #include "bin/utils.h"
8 #include "bin/log.h"
8 9
9 static void FormatMessageIntoBuffer(DWORD code, 10 static void FormatMessageIntoBuffer(DWORD code,
10 char* buffer, 11 char* buffer,
11 int buffer_length) { 12 int buffer_length) {
12 DWORD message_size = 13 DWORD message_size =
13 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 14 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
14 NULL, 15 NULL,
15 code, 16 code,
16 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 17 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
17 buffer, 18 buffer,
18 buffer_length, 19 buffer_length,
19 NULL); 20 NULL);
20 if (message_size == 0) { 21 if (message_size == 0) {
21 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { 22 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
22 fprintf(stderr, "FormatMessage failed %d\n", GetLastError()); 23 Log::PrintErr("FormatMessage failed %d\n", GetLastError());
23 } 24 }
24 snprintf(buffer, buffer_length, "OS Error %d", code); 25 snprintf(buffer, buffer_length, "OS Error %d", code);
25 } 26 }
26 buffer[buffer_length - 1] = '\0'; 27 buffer[buffer_length - 1] = '\0';
27 } 28 }
28 29
29 30
30 OSError::OSError() : sub_system_(kSystem), code_(0), message_(NULL) { 31 OSError::OSError() : sub_system_(kSystem), code_(0), message_(NULL) {
31 set_code(GetLastError()); 32 set_code(GetLastError());
32 33
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return ansi; 73 return ansi;
73 } 74 }
74 75
75 const char* StringUtils::Utf8ToSystemString(const char* utf8) { 76 const char* StringUtils::Utf8ToSystemString(const char* utf8) {
76 return const_cast<const char*>(Utf8ToSystemString(const_cast<char*>(utf8))); 77 return const_cast<const char*>(Utf8ToSystemString(const_cast<char*>(utf8)));
77 } 78 }
78 79
79 const char* StringUtils::SystemStringToUtf8(const char* str) { 80 const char* StringUtils::SystemStringToUtf8(const char* str) {
80 return const_cast<const char*>(Utf8ToSystemString(const_cast<char*>(str))); 81 return const_cast<const char*>(Utf8ToSystemString(const_cast<char*>(str)));
81 } 82 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698