Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aws-cloudwatch-log

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-cloudwatch-log - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

5

CHANGELOG.md

@@ -5,2 +5,7 @@ # Change Log

<a name="0.1.4"></a>
## [0.1.4](https://github.com/nicolasdao/aws-cloudwatch-logger/compare/v0.1.3...v0.1.4) (2023-01-17)
<a name="0.1.3"></a>

@@ -7,0 +12,0 @@ ## [0.1.3](https://github.com/nicolasdao/aws-cloudwatch-logger/compare/v0.1.2...v0.1.3) (2022-11-25)

74

index.js
/**
* Copyright (c) 2017, Neap Pty Ltd.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
* Copyright (c) 2017, Neap Pty Ltd.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

@@ -80,16 +80,16 @@

/**
* Adds logs to a AWS CloudWatch log stream
* @param {String|Object|Array} entry If type is Object it must be structured as follow: { message: ..., timestamp: ... }
* where 'message' must be a string and 'timestamp' must be an UTC date number
* (e.g. Date.now())
* If type is Array, then each item must either be a string or an object { message: ..., timestamp: ... }
* following the same rules as above.
* @param {String} logGroupName [description]
* @param {String} logStreamName [description]
* @param {String} region [description]
* @param {Object} keys { accessKeyId: ..., secretAccessKey: ... }
* @param {String} sequenceToken [description]
* @param {Number} retryCount [description]
* @return {Promise} [description]
*/
* Adds logs to a AWS CloudWatch log stream
* @param {String|Object|Array} entry If type is Object it must be structured as follow: { message: ..., timestamp: ... }
* where 'message' must be a string and 'timestamp' must be an UTC date number
* (e.g. Date.now())
* If type is Array, then each item must either be a string or an object { message: ..., timestamp: ... }
* following the same rules as above.
* @param {String} logGroupName [description]
* @param {String} logStreamName [description]
* @param {String} region [description]
* @param {Object} keys { accessKeyId: ..., secretAccessKey: ... }
* @param {String} sequenceToken [description]
* @param {Number} retryCount [description]
* @return {Promise} [description]
*/
const addLogsToStream = (entry, logGroupName, logStreamName, region, keys={}, sequenceToken='', retryCount=0) => {

@@ -102,3 +102,3 @@ if (!logGroupName)

throw new Error('Missing required argument: \'entry\' is required.')
const entryType = typeof(entry)

@@ -108,11 +108,11 @@ const now = Date.now()

const events =
// entry is a message
entryType == 'string' ? [{ message: entry, timestamp: now }] :
// entry is a well-formatted log event
entryType == 'object' && entry.timestamp ? [{ message: entry.message, timestamp: entry.timestamp }] :
// entry is an array of items
entry.length > 0 ? entry.map(e =>
typeof(e) == 'string' ? { message: e, timestamp: now } :
e.timestamp ? { message: e.message, timestamp: e.timestamp } : null).filter(x => x)
: null
// entry is a message
entryType == 'string' ? [{ message: entry, timestamp: now }] :
// entry is a well-formatted log event
entryType == 'object' && entry.timestamp ? [{ message: entry.message, timestamp: entry.timestamp }] :
// entry is an array of items
entry.length > 0 ? entry.map(e =>
typeof(e) == 'string' ? { message: e, timestamp: now } :
e.timestamp ? { message: e.message, timestamp: e.timestamp } : null).filter(x => x)
: null

@@ -142,3 +142,3 @@ const nothingToLog = events == null

.then(results => {
//console.log('Yes')
//console.log('Yes')
const token = results.data.nextSequenceToken

@@ -148,3 +148,3 @@ _sequenceTokens.set(tokenKey, token)

.catch(err => {
//console.log('Oops')
//console.log('Oops')
const token = err.response && err.response.data && err.response.data.expectedSequenceToken

@@ -157,3 +157,7 @@ if (token) {

else
console.error(err.response.data)
if (err.response && err.response.data) {
err = err.response.data
}
console.error(err)
})

@@ -164,3 +168,3 @@ }

const makeQuerablePromise = promise => {
// Don't modify any promise that has been already modified.
// Don't modify any promise that has been already modified.
if (promise.isResolved) return promise

@@ -220,3 +224,3 @@

log = (...args) => {
// 1. Accumulate all logs
// 1. Accumulate all logs
const now = Date.now()

@@ -250,2 +254,2 @@ const logs = (args || []).map(x => ({ message: JSON.stringify(x), timestamp: now }))

Logger
}
}
{
"name": "aws-cloudwatch-log",
"version": "0.1.3",
"version": "0.1.4",
"description": "Fast & Simple Logging to AWS CloudWatch",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc