Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
putLogEvents = (Input: PutLogRequest, cb: any) => {
let existingLogs: any[] = []
Input.logGroupName = this.formatGroupName(Input.logGroupName)
this.ensureLogGroup(Input.logGroupName)
const path = this.getEncodedPath(Input)
if (this.fsModule.existsSync(path)) {
const data = this.fsModule.readFileSync(path, 'utf-8')
existingLogs = existingLogs.concat(JSON.parse(data))
}
const logs = existingLogs.concat(Input.logEvents)
const content = JSON.stringify(logs)
this.fsModule.writeFileSync(path, `${content}\n`, 'utf-8')
const result = {
logStreamName: Input.logStreamName,
nextSequenceToken: getRandomSequenceToken(),
}
return this.result(cb, result)
}
putLogEvents = (Input: PutLogRequest, cb: any) => {
this.ensureLogGroup(Input.logGroupName)
const existingLogs =
this.storage[Input.logGroupName][Input.logStreamName] || []
this.storage[Input.logGroupName][Input.logStreamName] = existingLogs.concat(
Input.logEvents
)
const result = {
logStreamName: Input.logStreamName,
nextSequenceToken: getRandomSequenceToken(),
}
return this.result(cb, result)
}