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: I0d9b65833b5edbc56e225d90957ab3eebb3baded
Reviewed-on: http://gerrit.chromium.org/gerrit/882
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
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 d34a9b2..fcefd2b 100644
--- a/main.cc
+++ b/main.cc
@@ -26,6 +26,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.
@@ -36,6 +41,7 @@
     log_flags |= chromeos::kLogToStderr;
   }
   chromeos::InitLog(log_flags);
+  logging::SetMinLogLevel(FLAGS_minloglevel);
 }
 
 // This callback will be invoked once udev has data about 
@@ -53,6 +59,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);