-
Notifications
You must be signed in to change notification settings - Fork 45
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
- Loading branch information
1 parent
991fa35
commit da6fefc
Showing
16 changed files
with
125 additions
and
15 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
56 changes: 56 additions & 0 deletions
56
src/main/java/com/aws/greengrass/util/NucleusLogsSummarizer.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,56 @@ | ||
/* | ||
* 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 NucleusLogsSummarizer { | ||
public static final String STARTING_SUBSEQUENCE = "+ j=3"; | ||
public static final String ENDING_SUBSEQUENCE_REGEX = "Nucleus exited ([0-9])*. Retrying 3 times"; | ||
|
||
private NucleusLogsSummarizer() { | ||
} | ||
|
||
/** | ||
* 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.equals(STARTING_SUBSEQUENCE)) { | ||
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
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