Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5782f727 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "init: warn slow action"

parents 8cbc8952 b1a309ac
Loading
Loading
Loading
Loading
+5 −3
Original line number Original line Diff line number Diff line
@@ -118,14 +118,16 @@ void Action::ExecuteCommand(const Command& command) const {
    Timer t;
    Timer t;
    int result = command.InvokeFunc();
    int result = command.InvokeFunc();


    // TODO: this should probably be changed to "if (failed || took a long time)"...
    double duration_ms = t.duration() * 1000;
    if (android::base::GetMinimumLogSeverity() <= android::base::DEBUG) {
    // Any action longer than 50ms will be warned to user as slow operation
    if (duration_ms > 50.0 ||
        android::base::GetMinimumLogSeverity() <= android::base::DEBUG) {
        std::string trigger_name = BuildTriggersString();
        std::string trigger_name = BuildTriggersString();
        std::string cmd_str = command.BuildCommandString();
        std::string cmd_str = command.BuildCommandString();
        std::string source = command.BuildSourceString();
        std::string source = command.BuildSourceString();


        LOG(INFO) << "Command '" << cmd_str << "' action=" << trigger_name << source
        LOG(INFO) << "Command '" << cmd_str << "' action=" << trigger_name << source
                  << " returned " << result << " took " << t.duration() << "s";
                  << " returned " << result << " took " << duration_ms << "ms.";
    }
    }
}
}