OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium OS 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 <time.h> |
| 6 #include <string> |
| 7 #include <syslog.h> |
| 8 |
| 9 #include "shill/shill_logging.h" |
| 10 #include "shill/shill_daemon.h" |
| 11 #include "shill/dbus_control.h" |
| 12 |
| 13 using std::string; |
| 14 |
| 15 /* |
| 16 DEFINE_string(config_dir, "", |
| 17 "Directory to read confguration settings."); |
| 18 DEFINE_string(default_config_dir, "", |
| 19 "Directory to read default configuration settings (Read Only)."); |
| 20 */ |
| 21 namespace google { |
| 22 class LogSinkSyslog : public google::LogSink { |
| 23 public: |
| 24 LogSinkSyslog() { |
| 25 openlog("shill", |
| 26 LOG_PID, // Options |
| 27 LOG_LOCAL3); // 5,6,7 are taken |
| 28 } |
| 29 |
| 30 virtual void send(LogSeverity severity, const char* /* full_filename */, |
| 31 const char* base_filename, int line, |
| 32 const struct ::tm* /* tm_time */, |
| 33 const char* message, size_t message_len) { |
| 34 static const int glog_to_syslog[NUM_SEVERITIES] = { |
| 35 LOG_INFO, LOG_WARNING, LOG_ERR, LOG_CRIT}; |
| 36 CHECK(severity < NUM_SEVERITIES && severity >= 0); |
| 37 |
| 38 syslog(glog_to_syslog[severity], |
| 39 "%s:%d %.*s", |
| 40 base_filename, line, message_len, message); |
| 41 } |
| 42 |
| 43 virtual ~LogSinkSyslog() { |
| 44 closelog(); |
| 45 } |
| 46 }; |
| 47 } // namespace google |
| 48 |
| 49 |
| 50 int main(int /* argc */, char** argv) { |
| 51 /* |
| 52 FilePath config_dir(FLAGS_config_dir); |
| 53 FilePath default_config_dir(FLAGS_default_config_dir.empty() ? |
| 54 shill::Config::kShillDefaultPrefsDir : |
| 55 FLAGS_default_config_dir); |
| 56 */ |
| 57 google::LogSinkSyslog syslog_sink; |
| 58 |
| 59 google::InitGoogleLogging(argv[0]); |
| 60 google::AddLogSink(&syslog_sink); |
| 61 shill::Config config; /* (config_dir, default_config_dir) */ |
| 62 |
| 63 // TODO(pstew): This should be chosen based on config |
| 64 shill::ControlInterface *control_interface = new shill::DBusControl(); |
| 65 |
| 66 shill::Daemon daemon(&config, control_interface); |
| 67 daemon.Run(); |
| 68 |
| 69 return 0; |
| 70 } |
OLD | NEW |