blob: 9c3382829f034436edb26748b32a4e9b341c1512 [file] [log] [blame]
// Copyright 2016 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <iostream>
#include "garnet/bin/trace/commands/list_categories.h"
#include "lib/fxl/logging.h"
namespace tracing {
Command::Info ListCategories::Describe() {
return Command::Info{[](component::StartupContext* context) {
return std::make_unique<ListCategories>(context);
},
"list-categories",
"list all known categories",
{}};
}
ListCategories::ListCategories(component::StartupContext* context)
: CommandWithTraceController(context) {}
void ListCategories::Start(const fxl::CommandLine& command_line) {
if (!(command_line.options().empty() &&
command_line.positional_args().empty())) {
FXL_LOG(ERROR) << "We encountered unknown options, please check your "
<< "command invocation";
Done(1);
return;
}
trace_controller()->GetKnownCategories(
[this](
std::vector<fuchsia::tracing::KnownCategory> known_categories) {
out() << "Known categories" << std::endl;
for (const auto& it : known_categories) {
out() << " " << it.name << ": " << it.description
<< std::endl;
}
Done(0);
});
}
} // namespace tracing