-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved Logging and Manual Tests (#14)
* Add ListHandler with UnitTests * Move duplicate handler code into super class * Add capibility to log exceptions * Add guide on how to test changes manually E2E * Fix pre-commit failing check GetAtt was not found by pre-commit. Removed it from the yaml.
- Loading branch information
Showing
10 changed files
with
94 additions
and
31 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
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
38 changes: 38 additions & 0 deletions
38
...psworkscm-server/src/main/java/software/amazon/opsworkscm/server/utils/LoggerWrapper.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,38 @@ | ||
package software.amazon.opsworkscm.server.utils; | ||
|
||
import software.amazon.cloudformation.proxy.Logger; | ||
|
||
public class LoggerWrapper { | ||
|
||
Logger logger; | ||
|
||
private static final String infoPrefix = "[INFO] "; | ||
private static final String errorPrefix = "[ERROR] "; | ||
|
||
public LoggerWrapper(Logger logger) { | ||
this.logger = logger; | ||
} | ||
|
||
public void log(final String message) { | ||
info(message); | ||
} | ||
|
||
public void info(final String message) { | ||
logger.log(infoPrefix + message); | ||
} | ||
|
||
public void error(final String message) { | ||
logger.log(errorPrefix + message); | ||
} | ||
|
||
public void error(final String message, final Exception e) { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(errorPrefix).append(message).append('\n'); | ||
sb.append(e.toString()).append('\n'); | ||
for (StackTraceElement stackTraceElement : e.getStackTrace()) { | ||
sb.append('\t').append("at ").append(stackTraceElement.toString()).append('\n'); | ||
} | ||
logger.log(sb.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Resources: | ||
MyChefServer: | ||
Type: AWS::OpsWorksCM::Server | ||
Properties: | ||
BackupRetentionCount: 12 | ||
DisableAutomatedBackup: False | ||
Engine: 'ChefAutomate' | ||
EngineVersion: '2' | ||
EngineModel: 'Single' | ||
InstanceProfileArn: "arn:aws:iam::<ACCOUNT_ID>:instance-profile/opsworks-cm-ec2-role" | ||
InstanceType: 'm4.xlarge' | ||
PreferredBackupWindow: '08:00' | ||
PreferredMaintenanceWindow: 'Fri:08:00' | ||
ServiceRoleArn: "arn:aws:iam::<ACCOUNT_ID>:role/opsworks-cm-service-role" |