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

Side by Side Diff: chromeos/network/network_handler_callbacks.cc

Issue 14876021: Re-factor network_event_log (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 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 | Annotate | Revision Log
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 #include "chromeos/network/network_handler_callbacks.h" 5 #include "chromeos/network/network_handler_callbacks.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chromeos/network/network_event_log.h" 9 #include "chromeos/network/network_event_log.h"
10 10
11 namespace chromeos { 11 namespace chromeos {
12 namespace network_handler { 12 namespace network_handler {
13 13
14 const char kLogModule[] = "ShillError";
15
16 // These are names of fields in the error data dictionary for ErrorCallback. 14 // These are names of fields in the error data dictionary for ErrorCallback.
17 const char kErrorName[] = "errorName"; 15 const char kErrorName[] = "errorName";
18 const char kErrorMessage[] = "errorMessage"; 16 const char kErrorMessage[] = "errorMessage";
19 const char kServicePath[] = "servicePath"; 17 const char kServicePath[] = "servicePath";
20 18
21 base::DictionaryValue* CreateErrorData(const std::string& service_path, 19 base::DictionaryValue* CreateErrorData(const std::string& service_path,
22 const std::string& error_name, 20 const std::string& error_name,
23 const std::string& error_message) { 21 const std::string& error_message) {
24 base::DictionaryValue* error_data(new base::DictionaryValue); 22 base::DictionaryValue* error_data(new base::DictionaryValue);
25 error_data->SetString(kErrorName, error_name); 23 error_data->SetString(kErrorName, error_name);
26 error_data->SetString(kErrorMessage, error_message); 24 error_data->SetString(kErrorMessage, error_message);
27 if (!service_path.empty()) 25 if (!service_path.empty())
28 error_data->SetString(kServicePath, service_path); 26 error_data->SetString(kServicePath, service_path);
29 return error_data; 27 return error_data;
30 } 28 }
31 29
32 void ShillErrorCallbackFunction(const std::string& module, 30 void ShillErrorCallbackFunction(const std::string& path,
33 const std::string& path,
34 const ErrorCallback& error_callback, 31 const ErrorCallback& error_callback,
35 const std::string& error_name, 32 const std::string& error_name,
36 const std::string& error_message) { 33 const std::string& error_message) {
37 std::string error = "Shill Error in " + module; 34 std::string error = "Shill Error";
38 if (!path.empty()) 35 if (!path.empty())
39 error += " For " + path; 36 error += " For " + path;
40 error += ": " + error_name + " : " + error_message; 37 error += ": " + error_name;
41 LOG(ERROR) << error; 38 NET_LOG_ERROR(error, error_message);
pneubeck (no reviews) 2013/05/13 13:16:25 the file/line that is logged by NET_LOG_ERROR will
stevenjb 2013/05/13 19:36:39 I considered that, but I really think that is over
pneubeck (no reviews) 2013/05/16 08:21:07 I don't see a overkill on the perfomance side: the
42 network_event_log::AddEntry(kLogModule, module, error); 39 LOG(ERROR) << error << " : " << error_message;
43 if (error_callback.is_null()) 40 if (error_callback.is_null())
44 return; 41 return;
45 scoped_ptr<base::DictionaryValue> error_data( 42 scoped_ptr<base::DictionaryValue> error_data(
46 CreateErrorData(path, error_name, error_message)); 43 CreateErrorData(path, error_name, error_message));
47 error_callback.Run(error_name, error_data.Pass()); 44 error_callback.Run(error_name, error_data.Pass());
48 } 45 }
49 46
50 } // namespace network_handler 47 } // namespace network_handler
51 } // namespace chromeos 48 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698