-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tracing macros to addressresolve (#27180)
* Dnssd tracing * Enable log-json-tracing for minmdns * Centralize command line tracing args, add tracing to minmdns * Make address resolve compile * log errors and make shutdown actually work * Reformat and add tracing for address lookup results * Restyled by whitespace * Restyled by clang-format * Restyled by gn * Fixed quotes on other macros too * Restyled by clang-format * Make advertiser support ctrl+c * Address review comments * Add better help on what tracing destinations exist * Restyled by clang-format * Fix typo in include and make tv casting app dependencies include the command line tracing support because it includes CHIPCommand.h * Fix compile of tv-casting * Fix TraceHandlers compile if tracing is disabled (tizen has it disabled) * Restyle * Make linter happy * Make clang tidy happy * Explain nolint in comment --------- Co-authored-by: Andrei Litvin <[email protected]> Co-authored-by: Restyled.io <[email protected]>
- Loading branch information
Showing
21 changed files
with
387 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* | ||
* Copyright (c) 2023 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include <TracingCommandLineArgument.h> | ||
|
||
#include <lib/support/StringSplitter.h> | ||
#include <lib/support/logging/CHIPLogging.h> | ||
#include <tracing/log_json/log_json_tracing.h> | ||
#include <tracing/registry.h> | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace chip { | ||
namespace CommandLineApp { | ||
|
||
namespace { | ||
using ::chip::Tracing::ScopedRegistration; | ||
using ::chip::Tracing::LogJson::LogJsonBackend; | ||
|
||
// currently supported backends | ||
LogJsonBackend log_json_backend; | ||
|
||
// ScopedRegistration ensures register/unregister is met, as long | ||
// as the vector is cleared (and we do so when stopping tracing). | ||
std::vector<std::unique_ptr<ScopedRegistration>> tracing_backends; | ||
|
||
} // namespace | ||
|
||
void EnableTracingFor(const char * cliArg) | ||
{ | ||
chip::StringSplitter splitter(cliArg, ','); | ||
chip::CharSpan value; | ||
|
||
while (splitter.Next(value)) | ||
{ | ||
if (value.data_equal(CharSpan::fromCharString("log"))) | ||
{ | ||
if (!log_json_backend.IsInList()) | ||
{ | ||
tracing_backends.push_back(std::make_unique<ScopedRegistration>(log_json_backend)); | ||
} | ||
} | ||
else | ||
{ | ||
ChipLogError(AppServer, "Unknown trace destination: '%s'", std::string(value.data(), value.size()).c_str()); | ||
} | ||
} | ||
} | ||
|
||
void StopTracing() | ||
{ | ||
tracing_backends.clear(); | ||
} | ||
|
||
} // namespace CommandLineApp | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* | ||
* Copyright (c) 2023 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#pragma once | ||
|
||
/// A string with supported command line tracing targets | ||
/// to be pretty-printed in help strings if needed | ||
#define SUPPORTED_COMMAND_LINE_TRACING_TARGETS "log" | ||
|
||
namespace chip { | ||
namespace CommandLineApp { | ||
|
||
/// Enable tracing based on the given command line argument | ||
/// like "log" or "log,perfetto" or similar | ||
/// | ||
/// Single arguments as well as comma separated ones are accepted. | ||
/// | ||
/// Calling this method multiple times is ok and will enable each of | ||
/// the given tracing modules if not already enabled. | ||
void EnableTracingFor(const char * cliArg); | ||
|
||
/// If EnableTracingFor is called, this MUST be called as well | ||
/// to unregister tracing backends | ||
void StopTracing(); | ||
|
||
} // namespace CommandLineApp | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.