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

Side by Side Diff: third_party/leveldatabase/chromium_logger.h

Issue 800783003: LevelDB: Removed global prefix from base namespace: "::base" -> "base" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some git cl format changes. Created 6 years 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 | « no previous file | third_party/leveldatabase/env_chromium.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 #ifndef THIRD_PARTY_LEVELDATABASE_CHROMIUM_LOGGER_H_ 5 #ifndef THIRD_PARTY_LEVELDATABASE_CHROMIUM_LOGGER_H_
6 #define THIRD_PARTY_LEVELDATABASE_CHROMIUM_LOGGER_H_ 6 #define THIRD_PARTY_LEVELDATABASE_CHROMIUM_LOGGER_H_
7 7
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "third_party/leveldatabase/src/include/leveldb/env.h" 12 #include "third_party/leveldatabase/src/include/leveldb/env.h"
13 13
14 namespace leveldb { 14 namespace leveldb {
15 15
16 class ChromiumLogger : public Logger { 16 class ChromiumLogger : public Logger {
17 public: 17 public:
18 explicit ChromiumLogger(base::File* f) : file_(f) {} 18 explicit ChromiumLogger(base::File* f) : file_(f) {}
19 virtual ~ChromiumLogger() {} 19 virtual ~ChromiumLogger() {}
20 virtual void Logv(const char* format, va_list ap) { 20 virtual void Logv(const char* format, va_list ap) {
21 const base::PlatformThreadId thread_id = 21 const base::PlatformThreadId thread_id = base::PlatformThread::CurrentId();
22 ::base::PlatformThread::CurrentId();
23 22
24 // We try twice: the first time with a fixed-size stack allocated buffer, 23 // We try twice: the first time with a fixed-size stack allocated buffer,
25 // and the second time with a much larger dynamically allocated buffer. 24 // and the second time with a much larger dynamically allocated buffer.
26 char buffer[500]; 25 char buffer[500];
27 for (int iter = 0; iter < 2; iter++) { 26 for (int iter = 0; iter < 2; iter++) {
28 char* base; 27 char* base;
29 int bufsize; 28 int bufsize;
30 if (iter == 0) { 29 if (iter == 0) {
31 bufsize = sizeof(buffer); 30 bufsize = sizeof(buffer);
32 base = buffer; 31 base = buffer;
33 } else { 32 } else {
34 bufsize = 30000; 33 bufsize = 30000;
35 base = new char[bufsize]; 34 base = new char[bufsize];
36 } 35 }
37 char* p = base; 36 char* p = base;
38 char* limit = base + bufsize; 37 char* limit = base + bufsize;
39 38
40 ::base::Time::Exploded t; 39 base::Time::Exploded t;
41 ::base::Time::Now().LocalExplode(&t); 40 base::Time::Now().LocalExplode(&t);
42 41
43 p += ::base::snprintf(p, limit - p, 42 p += base::snprintf(p, limit - p,
44 "%04d/%02d/%02d-%02d:%02d:%02d.%03d %" PRIu64 " ", 43 "%04d/%02d/%02d-%02d:%02d:%02d.%03d %" PRIu64 " ",
45 t.year, 44 t.year,
46 t.month, 45 t.month,
47 t.day_of_month, 46 t.day_of_month,
48 t.hour, 47 t.hour,
49 t.minute, 48 t.minute,
50 t.second, 49 t.second,
51 t.millisecond, 50 t.millisecond,
52 static_cast<uint64>(thread_id)); 51 static_cast<uint64>(thread_id));
53 52
(...skipping 28 matching lines...) Expand all
82 } 81 }
83 } 82 }
84 83
85 private: 84 private:
86 scoped_ptr<base::File> file_; 85 scoped_ptr<base::File> file_;
87 }; 86 };
88 87
89 } // namespace leveldb 88 } // namespace leveldb
90 89
91 #endif // THIRD_PARTY_LEVELDATABASE_CHROMIUM_LOGGER_H_ 90 #endif // THIRD_PARTY_LEVELDATABASE_CHROMIUM_LOGGER_H_
OLDNEW
« no previous file with comments | « no previous file | third_party/leveldatabase/env_chromium.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698