Skip to content

Commit

Permalink
Bugfix: if use use the same naming of logger, the output of the first…
Browse files Browse the repository at this point in the history
… logger would be dismissed (#581)

* Bugfix: if use use the same naming of logger, the output of the first logger would be dismissed

* Update PreInstallListener.java
  • Loading branch information
zhou9584 authored Aug 23, 2023
1 parent bc69a7f commit dc67084
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
9 changes: 4 additions & 5 deletions agent/src/main/resources/logback-common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
</appender>

<appender name ="asyncAlarm" class= "ch.qos.logback.classic.AsyncAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${logging.console.level:-WARN}</level>
</filter>
<discardingThreshold >20</discardingThreshold>
<queueSize>256</queueSize>
<neverBlock>true</neverBlock>
Expand All @@ -62,16 +65,12 @@
<logger name="com.microsoft" level="debug" additivity="false">
<appender-ref ref="syslog"/>
<appender-ref ref="STDOUT"/>
<appender-ref ref="asyncAlarm"/>
</logger>
<logger name="logger.devices" level="debug" additivity="false">
</logger>
<logger name="access" level="info" additivity="false">
<appender-ref ref="accessLog"/>
</logger>
<logger name="com.microsoft" level="warn" additivity="false">
<appender-ref ref="asyncAlarm"/>
</logger>
<logger name="access" level="warn" additivity="false">
<appender-ref ref="asyncAlarm"/>
</logger>
</configuration>
9 changes: 4 additions & 5 deletions center/src/main/resources/logback-common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
</appender>

<appender name ="asyncAlarm" class= "ch.qos.logback.classic.AsyncAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${logging.console.level:-WARN}</level>
</filter>
<discardingThreshold >20</discardingThreshold>
<queueSize>256</queueSize>
<neverBlock>true</neverBlock>
Expand All @@ -62,16 +65,12 @@
<logger name="com.microsoft" level="debug" additivity="false">
<appender-ref ref="syslog"/>
<appender-ref ref="STDOUT"/>
<appender-ref ref="asyncAlarm"/>
</logger>
<logger name="logger.devices" level="debug" additivity="false">
</logger>
<logger name="access" level="info" additivity="false">
<appender-ref ref="accessLog"/>
</logger>
<logger name="com.microsoft" level="warn" additivity="false">
<appender-ref ref="asyncAlarm"/>
</logger>
<logger name="access" level="warn" additivity="false">
<appender-ref ref="asyncAlarm"/>
</logger>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ public void onDeviceConnected(DeviceInfo deviceInfo) {
if (!appFile.isFile()) {
continue;
}
try {
// install app
deviceDriverManager.installApp(deviceInfo, appFile.getAbsolutePath(), classLogger);

// install app
if (deviceDriverManager.installApp(deviceInfo, appFile.getAbsolutePath(), classLogger)) {
classLogger.info("Pre-Install {} successfully", appFile.getAbsolutePath());
} catch (Exception e) {
} else {
String errorMessage = String.format("Pre-Install %s failed", appFile.getAbsolutePath());
classLogger.error(errorMessage, e);
classLogger.warn(errorMessage);
try {
FlowUtil.retryAndSleepWhenFalse(3, 10, () -> {
// try to uninstall app first
Expand All @@ -64,17 +64,17 @@ public void onDeviceConnected(DeviceInfo deviceInfo) {
if (!StringUtils.isEmpty(res.getString(StorageFileInfo.ParserKey.PKG_NAME))) {
deviceDriverManager.uninstallApp(deviceInfo, res.getString(StorageFileInfo.ParserKey.PKG_NAME), classLogger);
}
} catch (Exception e1) {
} catch (Exception e) {
classLogger.warn("Uninstall origin app of {} failed", appFile.getName(), e);
}
// install app
return deviceDriverManager.installApp(deviceInfo, appFile.getAbsolutePath(), classLogger);
});
} catch (Exception e2) {
classLogger.warn("Uninstall origin app of {} failed", appFile.getName(), e2);
} catch (Exception e1) {
classLogger.warn("Uninstall origin app of {} failed", appFile.getName(), e1);
if (Const.PreInstallFailurePolicy.SHUTDOWN.equals(
agentManagementService.getPreInstallFailurePolicy())) {
throw new HydraLabRuntimeException(HttpStatus.INTERNAL_SERVER_ERROR.value(), errorMessage, e2);
throw new HydraLabRuntimeException(HttpStatus.INTERNAL_SERVER_ERROR.value(), errorMessage, e1);
}
}
}
Expand Down

0 comments on commit dc67084

Please sign in to comment.