-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pipe system logs to nucleus log path (#1661)
- Loading branch information
1 parent
00caf83
commit 47a6579
Showing
22 changed files
with
180 additions
and
23 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
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
58 changes: 58 additions & 0 deletions
58
src/main/java/com/aws/greengrass/util/LoaderLogsSummarizer.java
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,58 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.aws.greengrass.util; | ||
|
||
import java.util.Scanner; | ||
|
||
public final class LoaderLogsSummarizer { | ||
public static final String STARTING_SUBSEQUENCE_REGEX = | ||
"^Nucleus exited ([0-9])*\\.\\s*(Attempt 2 out of 3|Retrying 2 times)$"; | ||
public static final String ENDING_SUBSEQUENCE_REGEX = | ||
"^Nucleus exited ([0-9])*\\.\\s*(Attempt 3 out of 3|Retrying 3 times)$"; | ||
|
||
private LoaderLogsSummarizer() { | ||
} | ||
|
||
/** | ||
* Summarizes loader logs that can be published as part of the deployment status FSS message when deployment fails | ||
* with NRF. | ||
* | ||
* @param blob string blob containing loader logs | ||
* @return string containing summarized logs | ||
*/ | ||
public static String summarizeLogs(String blob) { | ||
try (Scanner scanner = new Scanner(blob)) { | ||
StringBuilder parsedLogsStringBuilder = new StringBuilder(); | ||
|
||
// Skip until the last restart failure | ||
while (scanner.hasNextLine()) { | ||
String line = scanner.nextLine(); | ||
// process the line | ||
if (line.matches(STARTING_SUBSEQUENCE_REGEX)) { | ||
break; | ||
} | ||
} | ||
|
||
while (scanner.hasNextLine()) { | ||
String line = scanner.nextLine(); | ||
|
||
if (line.matches(ENDING_SUBSEQUENCE_REGEX)) { | ||
parsedLogsStringBuilder.append(line); | ||
break; | ||
} | ||
|
||
if (line.startsWith("+")) { | ||
continue; | ||
} | ||
|
||
parsedLogsStringBuilder.append(line).append(System.lineSeparator()); | ||
} | ||
|
||
scanner.close(); | ||
return parsedLogsStringBuilder.toString(); | ||
} | ||
} | ||
} |
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
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.