From 254d22e5fd79f99d9af20338187bf60538f59720 Mon Sep 17 00:00:00 2001 From: Luigi Semenzato Date: Mon, 21 Apr 2014 14:33:32 -0700 Subject: [PATCH] metrics_daemon: log to syslog Also log to stderr when not running as daemon. BUG=chromium:364700 TEST=manually verified in both daemon and non-daemon modes Change-Id: If62f70c1d327a5ecaf3075b6689b83a1494c09d5 Reviewed-on: https://chromium-review.googlesource.com/199380 Tested-by: Luigi Semenzato Reviewed-by: Daniel Erat Commit-Queue: Luigi Semenzato --- metrics/metrics_daemon.cc | 4 ---- metrics/metrics_daemon_main.cc | 8 ++++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/metrics/metrics_daemon.cc b/metrics/metrics_daemon.cc index 47d74fa98..d1eb25e60 100644 --- a/metrics/metrics_daemon.cc +++ b/metrics/metrics_daemon.cc @@ -928,8 +928,6 @@ void MetricsDaemon::ReportDailyUse(int use_seconds) { void MetricsDaemon::SendSample(const string& name, int sample, int min, int max, int nbuckets) { - DLOG(INFO) << "received metric: " << name << " " << sample << " " - << min << " " << max << " " << nbuckets; metrics_lib_->SendToUMA(name, sample, min, max, nbuckets); } @@ -993,8 +991,6 @@ void MetricsDaemon::SendCrashFrequencySample( void MetricsDaemon::SendLinearSample(const string& name, int sample, int max, int nbuckets) { - DLOG(INFO) << "received linear metric: " << name << " " << sample << " " - << max << " " << nbuckets; // TODO(semenzato): add a proper linear histogram to the Chrome external // metrics API. LOG_IF(FATAL, nbuckets != max + 1) << "unsupported histogram scale"; diff --git a/metrics/metrics_daemon_main.cc b/metrics/metrics_daemon_main.cc index 5fb7507e7..ffe74f2a7 100644 --- a/metrics/metrics_daemon_main.cc +++ b/metrics/metrics_daemon_main.cc @@ -3,8 +3,10 @@ // found in the LICENSE file. +#include #include #include +#include #include #include @@ -43,7 +45,13 @@ const std::string MetricsMainDiskStatsPath() { } int main(int argc, char** argv) { + CommandLine::Init(argc, argv); google::ParseCommandLineFlags(&argc, &argv, true); + + // Also log to stderr when not running as daemon. + chromeos::InitLog(chromeos::kLogToSyslog | chromeos::kLogHeader | + (FLAGS_daemon ? 0 : chromeos::kLogToStderr)); + MetricsLibrary metrics_lib; metrics_lib.Init(); MetricsDaemon daemon;