Skip to content

Commit

Permalink
Merge pull request #219 from microsoft/reducestreamverbosity
Browse files Browse the repository at this point in the history
Eliminate unnecessary argument from FunctionTracer and derived classes
  • Loading branch information
abeltrano authored Mar 13, 2024
2 parents 82b856e + 70ca9b2 commit 0e7d9c2
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/common/service/NetRemoteApiTrace.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

using namespace Microsoft::Net::Remote::Service::Tracing;

NetRemoteApiTrace::NetRemoteApiTrace(bool deferEnter, plog::Severity logSeverityEnter, plog::Severity logSeverityExit, std::source_location location) :
logging::FunctionTracer(logSeverityEnter, logSeverityExit, LogTracePrefix, {}, deferEnter, location)
NetRemoteApiTrace::NetRemoteApiTrace(bool deferEnter, plog::Severity logSeverity, std::source_location location) :
logging::FunctionTracer(logSeverity, LogTracePrefix, {}, deferEnter, location)
{}
5 changes: 2 additions & 3 deletions src/common/service/NetRemoteApiTrace.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ struct NetRemoteApiTrace :
* @brief Construct a new NetRemoteApiTrace object.
*
* @param deferEnter Whether to defer the entry log message upon construction.
* @param logSeverityEnter The log severity to use when tracing function entrance.
* @param logSeverityExit The log severity to use when tracing function exit.
* @param logSeverity The default log severity to use when tracing.
* @param location The source code location of the function call.
*/
NetRemoteApiTrace(bool deferEnter = false, plog::Severity logSeverityEnter = LogSeverityDefaultApi, plog::Severity logSeverityExit = LogSeverityDefaultApi, std::source_location location = std::source_location::current());
NetRemoteApiTrace(bool deferEnter = false, plog::Severity logSeverity = LogSeverityDefaultApi, std::source_location location = std::source_location::current());

protected:
static constexpr auto LogSeverityDefaultApi{ plog::Severity::info };
Expand Down
4 changes: 2 additions & 2 deletions src/common/service/NetRemoteWifiApiTrace.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ using namespace Microsoft::Net::Remote::Service::Tracing;
using Microsoft::Net::Remote::Wifi::WifiAccessPointOperationStatus;
using Microsoft::Net::Remote::Wifi::WifiAccessPointOperationStatusCode;

NetRemoteWifiApiTrace::NetRemoteWifiApiTrace(std::optional<std::string> accessPointId, const WifiAccessPointOperationStatus* operationStatus, plog::Severity logSeverityEnter, plog::Severity logSeverityExit, std::source_location location) :
NetRemoteApiTrace(/* deferEnter= */ true, logSeverityEnter, logSeverityExit, location),
NetRemoteWifiApiTrace::NetRemoteWifiApiTrace(std::optional<std::string> accessPointId, const WifiAccessPointOperationStatus* operationStatus, plog::Severity logSeverity, std::source_location location) :
NetRemoteApiTrace(/* deferEnter= */ true, logSeverity, location),
m_accessPointId(std::move(accessPointId)),
m_operationStatus(operationStatus)
{
Expand Down
2 changes: 1 addition & 1 deletion src/common/service/NetRemoteWifiApiTrace.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct NetRemoteWifiApiTrace :
* @param operationStatus The result status of the operation, if present.
* @param location The source code location of the function call.
*/
NetRemoteWifiApiTrace(std::optional<std::string> accessPointId = std::nullopt, const Microsoft::Net::Remote::Wifi::WifiAccessPointOperationStatus* operationStatus = nullptr, plog::Severity logSeverityEnter = LogSeverityDefaultApi, plog::Severity logSeverityExit = LogSeverityDefaultApi, std::source_location location = std::source_location::current());
NetRemoteWifiApiTrace(std::optional<std::string> accessPointId = std::nullopt, const Microsoft::Net::Remote::Wifi::WifiAccessPointOperationStatus* operationStatus = nullptr, plog::Severity logSeverity = LogSeverityDefaultApi, std::source_location location = std::source_location::current());

/**
* @brief Destroy the NetRemoteWifiApiTrace object.
Expand Down
10 changes: 5 additions & 5 deletions src/common/shared/logging/FunctionTracer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ BuildValueList(const std::vector<std::pair<std::string, std::string>>& values, s
}
} // namespace detail

FunctionTracer::FunctionTracer(plog::Severity logSeverityEnter, plog::Severity logSeverityExit, std::string logPrefix, std::vector<std::pair<std::string, std::string>> arguments, bool deferEnter, std::source_location location) :
m_logSeverityEnter(logSeverityEnter),
m_logSeverityExit(logSeverityExit),
FunctionTracer::FunctionTracer(plog::Severity logSeverity, std::string logPrefix, std::vector<std::pair<std::string, std::string>> arguments, bool deferEnter, std::source_location location) :
m_logSeverityEnter(logSeverity),
m_logSeverityExit(logSeverity),
m_logPrefix(std::move(logPrefix)),
m_location(location),
m_functionName(m_location.function_name()),
Expand Down Expand Up @@ -119,13 +119,13 @@ FunctionTracer::SetFailed() noexcept
}

void
FunctionTracer::SetEnterLogSeverity(plog::Severity logSeverityEnter) noexcept
FunctionTracer::SetEnterLogSeverity(plog::Severity logSeverity) noexcept
{
if (m_entered) {
LOGW << "warning: calling SetEnterLogSeverity after entered log has already been printed; this will have no effect.";
}

m_logSeverityEnter = logSeverityEnter;
m_logSeverityEnter = logSeverity;
}

void
Expand Down
9 changes: 4 additions & 5 deletions src/common/shared/logging/include/logging/FunctionTracer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ struct FunctionTracer
/**
* @brief Construct a new FunctionTracer object.
*
* @param logSeverityEnter The severity to log entrance with.
* @param logSeverityExit The severity to log exit with.
* @param logSeverity The default severity to log with.
* @param logPrefix The prefix to use for both log messages.
* @param arguments The arguments the function was called with.
* @param deferEnter Whether to defer the call to Enter().
* @param location The source location information of the caller.
*/
FunctionTracer(plog::Severity logSeverityEnter = LogSeverityEnterDefault, plog::Severity logSeverityExit = LogSeverityExitDefault, std::string logPrefix = {}, std::vector<std::pair<std::string, std::string>> arguments = {}, bool deferEnter = false, std::source_location location = std::source_location::current());
FunctionTracer(plog::Severity logSeverity = LogSeverityEnterDefault, std::string logPrefix = {}, std::vector<std::pair<std::string, std::string>> arguments = {}, bool deferEnter = false, std::source_location location = std::source_location::current());

/**
* @brief Destroy the FunctionTracer object.
Expand Down Expand Up @@ -84,10 +83,10 @@ struct FunctionTracer
* @brief Manually set the log severity for the enter log message. This only has an effect if the object was created
* with deferEnter = true.
*
* @param logSeverityEnter The log severity to use when printing the entrance log message.
* @param logSeverity The log severity to use when printing the entrance log message.
*/
void
SetEnterLogSeverity(plog::Severity logSeverityEnter) noexcept;
SetEnterLogSeverity(plog::Severity logSeverity) noexcept;

/**
* @brief Manually set the log severity for the exit log message. This overrides the SetSucceeded and SetFailed methods.
Expand Down

0 comments on commit 0e7d9c2

Please sign in to comment.