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

Side by Side Diff: mojo/public/cpp/environment/lib/logging.cc

Issue 1765243002: Remove Mojo bindings environment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "mojo/public/cpp/environment/logging.h"
6
7 #include <stdint.h>
8
9 #include "mojo/public/cpp/environment/environment.h"
10
11 namespace mojo {
12 namespace internal {
13
14 namespace {
15
16 // Gets a pointer to the filename portion of |s|. Assumes that the filename
17 // follows the last slash or backslash in |s|, or is |s| if no slash or
18 // backslash is present.
19 //
20 // E.g., a pointer to "foo.cc" is returned for the following inputs: "foo.cc",
21 // "./foo.cc", ".\foo.cc", "/absolute/path/to/foo.cc",
22 // "relative/path/to/foo.cc", "C:\absolute\path\to\foo.cc", etc.
23 const char* GetFilename(const char* s) {
24 const char* rv = s;
25 while (*s) {
26 if (*s == '/' || *s == '\\')
27 rv = s + 1;
28 s++;
29 }
30 return rv;
31 }
32
33 } // namespace
34
35 // TODO(vtl): Maybe we should preserve the full path and strip it out at a
36 // different level instead?
37 LogMessage::LogMessage(MojoLogLevel log_level, const char* file, int line)
38 : log_level_(log_level), file_(GetFilename(file)), line_(line) {
39 }
40
41 LogMessage::~LogMessage() {
42 Environment::GetDefaultLogger()->LogMessage(
43 log_level_, file_, static_cast<uint32_t>(line_), stream_.str().c_str());
44 }
45
46 } // namespace internal
47 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/environment/lib/environment.cc ('k') | mojo/public/cpp/environment/lib/scoped_task_tracking.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698