Allow minimum log level to be set for cros-disks daemon.
BUG=chromium-os:15107
TEST=Built and ran on a Cr48 with different minimum log levels.
Change-Id: If8eb9c239cde62932f5a0ffdef344260f64245c5
Reviewed-on: http://gerrit.chromium.org/gerrit/879
Reviewed-by: Darin Petkov <[email protected]>
Tested-by: Ben Chan <[email protected]>
diff --git a/cros-disks.conf b/cros-disks.conf
index a3d59f8..9b46015 100644
--- a/cros-disks.conf
+++ b/cros-disks.conf
@@ -7,6 +7,11 @@
env CROS_DISKS_UID=213
env CROS_DISKS_GID=213
+# Minimum log level defined in base/logging.h.
+# 0:INFO, 1:WARNING, 2:ERROR, 3:ERROR_REPORT, 4:FATAL
+# Set to log only WARNING or above by default.
+env CROS_DISKS_MINLOGLEVEL=1
+
start on starting system-services and started dbus
stop on stopping system-services
@@ -14,5 +19,4 @@
expect fork
#exec /sbin/minijail --use-capabilities --uid="${CROS_DISKS_UID}" --gid="${CROS_DISKS_GID}" -- /opt/google/cros-disks/disks
-exec /opt/google/cros-disks/disks
-
+exec /opt/google/cros-disks/disks -minloglevel=${CROS_DISKS_MINLOGLEVEL}
diff --git a/main.cc b/main.cc
index 93e43a0..8e1a004 100644
--- a/main.cc
+++ b/main.cc
@@ -27,6 +27,11 @@
DEFINE_bool(foreground, false,
"Don't daemon()ize; run in foreground.");
+DEFINE_int32(minloglevel, logging::LOG_WARNING,
+ "Messages logged at a lower level than "
+ "this don't actually get logged anywhere");
+
+static const char kUsageMessage[] = "Chromium OS Disk Daemon";
// Always logs to the syslog and logs to stderr if
// we are running in the foreground.
@@ -37,6 +42,7 @@
log_flags |= chromeos::kLogToStderr;
}
chromeos::InitLog(log_flags);
+ logging::SetMinLogLevel(FLAGS_minloglevel);
}
// This callback will be invoked once udev has data about
@@ -54,6 +60,7 @@
int main(int argc, char** argv) {
::g_type_init();
g_thread_init(NULL);
+ google::SetUsageMessage(kUsageMessage);
google::ParseCommandLineFlags(&argc, &argv, true);
CommandLine::Init(argc, argv);