diff --git a/script/check-infra-if-index-changed b/script/check-infra-if-index-changed index 51f7ce2fc..18712bd0d 100755 --- a/script/check-infra-if-index-changed +++ b/script/check-infra-if-index-changed @@ -112,7 +112,7 @@ do_check() RADIO_NCP_PATH="$PWD/build/simulation/examples/apps/ncp/ot-rcp" RADIO_URL="spinel+hdlc+forkpty://${RADIO_NCP_PATH}?forkpty-arg=2" - sudo -E "$PWD/build/posix/src/posix/ot-daemon" -d7 -v -I wpan0 -B veth-a "${RADIO_URL}" & + sudo -E "$PWD/build/posix/src/posix/ot-daemon" -d5 -v -I wpan0 -B veth-a "${RADIO_URL}" & wait_for "state" "Done" || die "failed to start daemon" # verify this reset and factoryreset end immediately diff --git a/script/check-posix-pty b/script/check-posix-pty index f166a6b16..1480f8176 100755 --- a/script/check-posix-pty +++ b/script/check-posix-pty @@ -211,7 +211,7 @@ do_check() if [[ ${OT_DAEMON} == 'on' ]]; then # The log file is in our own tmp directory, so the redirect does not need sudo. # shellcheck disable=SC2024 - sudo -E "$PWD/build/posix/src/posix/ot-daemon" -d7 -v -I "${VALID_NETIF_NAME}" "${RADIO_URL}" >"${OT_DAEMON_OUTPUT}" 2>&1 & + sudo -E "$PWD/build/posix/src/posix/ot-daemon" -d5 -v -I "${VALID_NETIF_NAME}" "${RADIO_URL}" >"${OT_DAEMON_OUTPUT}" 2>&1 & OT_DAEMON_JOB=$! sleep 3 # macOS cannot explicitly set network interface name @@ -222,6 +222,9 @@ do_check() else OT_CTL=(sudo "${OT_CTL_PATH}") fi + # -d5 asks for debug logging; the daemon's output must carry OpenThread's own log lines, not only the + # syslog() lines of its startup. + timeout_run 10 grep -qE '\[(D|I)\] ' "${OT_DAEMON_OUTPUT}" || die 'the daemon does not log at the level -d asked for' "${OT_CTL[@]}" -I "${NETIF_NAME}" panid 0xface | grep 'Done' || die 'failed to set panid with ot-ctl' # verify supports options in OpenThread commands without separator -- @@ -250,8 +253,8 @@ do_check() die fi - # check_daemon_multicast_group reads INFO lines of the netif; `-d7` does not take - # effect, as main.c sets the level before the instance exists. + # check_daemon_multicast_group reads INFO lines of the netif; -d5 above gives them along + # with everything at DEBG, so settle on INFO for the rest of the run. "${OT_CTL[@]}" -I "${NETIF_NAME}" log level 4 | grep 'Done' || die 'failed to set log level' OT_CLI_CMD="${OT_CTL[*]} -I ${NETIF_NAME}" else diff --git a/src/posix/main.c b/src/posix/main.c index d4f8bf51e..e671b85b9 100644 --- a/src/posix/main.c +++ b/src/posix/main.c @@ -323,10 +323,11 @@ static otInstance *InitInstance(PosixConfig *aConfig) syslog(LOG_INFO, "Running %s", otGetVersionString()); syslog(LOG_INFO, "Thread version: %hu", otThreadGetVersion()); - IgnoreError(otLoggingSetLevel(aConfig->mLogLevel)); instance = otSysInit(&aConfig->mPlatformConfig); VerifyOrDie(instance != NULL, OT_EXIT_FAILURE); + // The instance starts at OPENTHREAD_CONFIG_LOG_LEVEL_INIT; a level set before it exists is lost. + IgnoreError(otLoggingSetLevel(aConfig->mLogLevel)); syslog(LOG_INFO, "Thread interface: %s", otSysGetThreadNetifName()); if (aConfig->mPlatformConfig.mCoprocessorType != OT_COPROCESSOR_RCP)