Skip to content

Commit

Permalink
fix: don't quote CloudWatch filter pattern (#702)
Browse files Browse the repository at this point in the history
fix: don't quote CloudWatch filter pattern (#702)

BREAKING CHANGE: The filter pattern to match CloudWatch Logs is now passed without modifications to the AWS API. If you're using the Jest `toHaveLog` or Chai `to.have.log` matchers you might need to quote your pattern, e.g. `toHaveLog(pattern) -> toHaveLog("${pattern}")` or `to.have.log(pattern) -> to.have.log("${pattern}")` to support special characters
  • Loading branch information
erezrokah committed Oct 21, 2022
1 parent ba36f4b commit aef13c0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/utils/cloudwatch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('cloudwatch utils', () => {
expect(cloudWatchLogs).toHaveBeenCalledWith({ region });
expect(filterLogEvents).toHaveBeenCalledTimes(1);
expect(filterLogEvents).toHaveBeenCalledWith({
filterPattern: `"${filterPattern}"`,
filterPattern,
interleaved: true,
limit: 1,
logGroupName,
Expand Down
3 changes: 1 addition & 2 deletions src/utils/cloudwatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ export const filterLogEvents = async (
region: string,
logGroupName: string,
startTime: number,
pattern: string,
filterPattern: string,
) => {
const cloudWatchLogs = new AWS.CloudWatchLogs({ region });
const filterPattern = `"${pattern}"`; // enclose with "" to support special characters

const { events = [] } = await cloudWatchLogs
.filterLogEvents({
Expand Down

0 comments on commit aef13c0

Please sign in to comment.