Comparing version
11
index.js
@@ -18,2 +18,3 @@ #!/usr/bin/env node | ||
var Getopt = require('node-getopt'); | ||
var os = require('os'); | ||
@@ -56,3 +57,3 @@ var DEFAULT_NUM_RECORDS = 30; // Default number of records to tail | ||
*/ | ||
function tail(logs, logGroup, numRecords, showTimes, showStreams, seenStreamTimestamps) { | ||
function tail(logs, logGroup, numRecords, showTimes, showStreams, seenStreamTimestamps, eol) { | ||
return logs.describeLogStreamsAsync({ | ||
@@ -134,2 +135,5 @@ logGroupName: logGroup, | ||
process.stdout.write(record.message); | ||
if (eol) { | ||
process.stdout.write(os.EOL); | ||
} | ||
}); | ||
@@ -152,2 +156,3 @@ Object.keys(newTimestamps).map(function (key) { | ||
['t', 'time', 'Show timestamps in log records'], | ||
['e', 'eol', 'Append platform end-of-line to log records'], | ||
['l', 'list', 'List available log groups'], | ||
@@ -198,3 +203,3 @@ ['p', 'profile=ARG', 'Select AWS profile'], | ||
function readNext() { | ||
return tail(logs, arg.argv[0], opt.num || DEFAULT_NUM_RECORDS, arg.options.time, arg.options.streams, seenStreamTimestamps) | ||
return tail(logs, arg.argv[0], opt.num || DEFAULT_NUM_RECORDS, arg.options.time, arg.options.streams, seenStreamTimestamps, arg.options.eol) | ||
.then(function () { | ||
@@ -210,3 +215,3 @@ return new Promise(function (resolve, reject) { setTimeout(resolve, FOLLOW_INTERVAL)}); | ||
var seenStreamTimestamps = {}; | ||
return tail(logs, arg.argv[0], opt.num || DEFAULT_NUM_RECORDS, arg.options.time, arg.options.streams, seenStreamTimestamps); | ||
return tail(logs, arg.argv[0], opt.num || DEFAULT_NUM_RECORDS, arg.options.time, arg.options.streams, seenStreamTimestamps, arg.options.eol); | ||
} | ||
@@ -213,0 +218,0 @@ }) |
{ | ||
"name": "cwtail", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "CloudWatch Logs Tail", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -48,2 +48,7 @@ # CloudWatch Logs Tail | ||
Records added by the CloudWatch Logs Agent may not end with an end-of-line sequence. | ||
Use the -e option to print the platform's end-of-line sequence after each log record: | ||
cwtail -e /var/log/syslog | ||
## Configuration | ||
@@ -50,0 +55,0 @@ |
10123
4.06%223
2.29%60
9.09%