Skip to content

Commit

Permalink
Fixed device related logging
Browse files Browse the repository at this point in the history
  • Loading branch information
themarpe committed Jul 31, 2023
1 parent 1289c3a commit 0e37dcd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/device/DeviceBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,12 @@ void DeviceBase::init2(Config cfg, const dai::Path& pathToMvcmd, tl::optional<co
// Apply nonExclusiveMode
config.board.nonExclusiveMode = config.nonExclusiveMode;

// Apply device specific logger level
{
auto deviceLogLevel = config.logLevel.value_or(spdlogLevelToLogLevel(logger::get_level()));
setLogOutputLevel(config.outputLogLevel.value_or(deviceLogLevel));
}

// Specify expected running mode
XLinkDeviceState_t expectedBootState = X_LINK_BOOTED;
if(config.nonExclusiveMode) {
Expand Down Expand Up @@ -676,7 +682,7 @@ void DeviceBase::init2(Config cfg, const dai::Path& pathToMvcmd, tl::optional<co
}

// Get embedded mvcmd or external with applied config
if(logger::get_level() == spdlog::level::debug) {
if(getLogOutputLevel() <= LogLevel::DEBUG) {
nlohmann::json jBoardConfig = config.board;
pimpl->logger.debug("Device - BoardConfig: {} \nlibnop:{}", jBoardConfig.dump(), spdlog::to_hex(utility::serialize(config.board)));
}
Expand Down Expand Up @@ -738,7 +744,7 @@ void DeviceBase::init2(Config cfg, const dai::Path& pathToMvcmd, tl::optional<co
std::unique_lock<std::mutex> lock(pimpl->rpcMutex);

// Log the request data
if(logger::get_level() == spdlog::level::trace) {
if(getLogOutputLevel() == LogLevel::TRACE) {
pimpl->logger.trace("RPC: {}", nlohmann::json::from_msgpack(request).dump());
}

Expand Down Expand Up @@ -821,7 +827,6 @@ void DeviceBase::init2(Config cfg, const dai::Path& pathToMvcmd, tl::optional<co
try {
auto level = spdlogLevelToLogLevel(logger::get_level());
setLogLevel(config.logLevel.value_or(level));
setLogOutputLevel(config.outputLogLevel.value_or(level));

// Sets system inforation logging rate. By default 1s
setSystemInformationLoggingRate(DEFAULT_SYSTEM_INFORMATION_LOGGING_RATE_HZ);
Expand Down Expand Up @@ -1367,7 +1372,7 @@ bool DeviceBase::startPipelineImpl(const Pipeline& pipeline) {
pipeline.serialize(schema, assets, assetStorage);

// if debug or lower
if(logger::get_level() <= spdlog::level::debug) {
if(getLogOutputLevel() <= LogLevel::DEBUG) {
nlohmann::json jSchema = schema;
pimpl->logger.debug("Schema dump: {}", jSchema.dump());
nlohmann::json jAssets = assets;
Expand Down

0 comments on commit 0e37dcd

Please sign in to comment.