OLD | NEW |
1 // Copyright (C) 2011 Google Inc. | 1 // Copyright (C) 2011 Google Inc. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 // Author: Philippe Liard | 15 // Author: Philippe Liard |
16 | 16 |
17 #ifndef I18N_PHONENUMBERS_DEFAULT_LOGGER_H_ | 17 #ifndef I18N_PHONENUMBERS_DEFAULT_LOGGER_H_ |
18 #define I18N_PHONENUMBERS_DEFAULT_LOGGER_H_ | 18 #define I18N_PHONENUMBERS_DEFAULT_LOGGER_H_ |
19 | 19 |
| 20 #include <stdio.h> |
| 21 |
20 #include <string> | 22 #include <string> |
21 | 23 |
22 #include "logger.h" | 24 #include "logger.h" |
23 | 25 |
24 using std::string; | 26 using std::string; |
25 | 27 |
26 // Make the logging functions private (not declared in logger.h) as the client | 28 // Make the logging functions private (not declared in logger.h) as the client |
27 // should not have any reason to use them. | 29 // should not have any reason to use them. |
28 namespace { | 30 namespace { |
29 | 31 |
(...skipping 11 matching lines...) Expand all Loading... |
41 } | 43 } |
42 }; | 44 }; |
43 | 45 |
44 template <> | 46 template <> |
45 struct ConvertToString<int> { | 47 struct ConvertToString<int> { |
46 static inline string DoWork(const int& n) { | 48 static inline string DoWork(const int& n) { |
47 char buffer[16]; | 49 char buffer[16]; |
48 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
49 _itoa_s(n, buffer, sizeof(buffer), 10); | 51 _itoa_s(n, buffer, sizeof(buffer), 10); |
50 #else | 52 #else |
51 std::snprintf(buffer, sizeof(buffer), "%d", n); | 53 snprintf(buffer, sizeof(buffer), "%d", n); |
52 #endif | 54 #endif |
53 return string(buffer); | 55 return string(buffer); |
54 } | 56 } |
55 }; | 57 }; |
56 | 58 |
57 class LoggerHandler { | 59 class LoggerHandler { |
58 public: | 60 public: |
59 LoggerHandler(Logger* impl) : impl_(impl) {} | 61 LoggerHandler(Logger* impl) : impl_(impl) {} |
60 | 62 |
61 ~LoggerHandler() { | 63 ~LoggerHandler() { |
(...skipping 26 matching lines...) Expand all Loading... |
88 virtual ~StdoutLogger() {} | 90 virtual ~StdoutLogger() {} |
89 | 91 |
90 virtual void WriteLevel(); | 92 virtual void WriteLevel(); |
91 virtual void WriteMessage(const string& msg); | 93 virtual void WriteMessage(const string& msg); |
92 }; | 94 }; |
93 | 95 |
94 } // namespace phonenumbers | 96 } // namespace phonenumbers |
95 } // namespace i18n | 97 } // namespace i18n |
96 | 98 |
97 #endif // I18N_PHONENUMBERS_DEFAULT_LOGGER_H_ | 99 #endif // I18N_PHONENUMBERS_DEFAULT_LOGGER_H_ |
OLD | NEW |