Skip to content

Commit dae2fef

Browse files
committed
modified the Style of the example
1 parent 258d82b commit dae2fef

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

javav2/example_code/cloudwatch/src/main/java/com/example/cloudwatch/CloudWatchLogsSearch.java

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,33 @@
2525
*/
2626
public class CloudWatchLogsSearch {
2727

28-
private static final String LOG_GROUP_NAME = "WeathertopJavaContainerLogs";
29-
private static final String LOG_STREAM_PREFIX = "weathertop-java-stream";
30-
private static final String PATTERN = "INFO";
31-
private static final Region REGION = Region.US_EAST_1;
32-
3328
public static void main(String[] args) {
29+
final String usage = """
30+
31+
Usage:
32+
<logGroupName> <logStreamName>
33+
34+
Where:
35+
logGroupName - The name of the log group (for example, WeathertopJavaContainerLogs).
36+
logStreamName - The name of the log stream (for example, weathertop-java-stream).
37+
pattern - the pattern to use (for example, INFO)
38+
39+
""";
40+
41+
if (args.length != 3) {
42+
System.out.print(usage);
43+
System.exit(1);
44+
}
45+
46+
String logGroupName = args[0] ;
47+
String logStreamName = args[1] ;
48+
String pattern = args[2] ;
49+
3450
CloudWatchLogsClient cwlClient = CloudWatchLogsClient.builder()
35-
.region(REGION)
51+
.region(Region.US_EAST_1)
3652
.build();
3753

38-
searchLogStreamsAndFilterEvents(cwlClient, LOG_GROUP_NAME, LOG_STREAM_PREFIX, PATTERN);
54+
searchLogStreamsAndFilterEvents(cwlClient, logGroupName, logStreamName, pattern);
3955
}
4056

4157
/**

0 commit comments

Comments
 (0)