Skip to content

Commit 5defca2

Browse files
committed
Adjust default log buffer to 100
1 parent cf4f166 commit 5defca2

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

bin/dropstack-logs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ program
1010
.arguments('[name]')
1111
.option('-f, --nofollow', 'Disable live updates.')
1212
.option('-r, --raw', 'Enable raw JSON outputs.')
13+
.option('-b, --logbuffer [lines]', 'Log buffering in lines [100]', 100)
1314
.action(name =>
1415
log({
1516
name: name,
1617
raw: program.raw,
17-
follow: !Boolean(program.nofollow)
18+
follow: !Boolean(program.nofollow),
19+
logbuffer: parseInt(program.logbuffer)
1820
})
1921
)
2022
.parse(process.argv);
2123

22-
function log({name, follow, raw}) {
24+
function log({name, follow, raw, logbuffer}) {
2325
configuration
2426
.load()
2527
.then(settings => {
@@ -39,22 +41,23 @@ function log({name, follow, raw}) {
3941
.then(settings => {
4042
process.stderr.write('\x1B[?25l'); //hide terminal cursor
4143
const es = new EventSource(
42-
`${settings.url}/deploys/${name || settings.serviceName}/logs?${!follow ? 'follow=' + follow : 'follow=true'}`,
44+
`${settings.url}/deploys/${name || settings.serviceName}/logs?${!follow
45+
? 'follow=' + follow
46+
: 'follow=true'}&tail=${logbuffer}`,
4347
{headers: {connection: 'keep-alive', 'cache-control': 'no-cache', authorization: `Bearer ${settings.token}`}}
4448
);
45-
if (!raw) process.stdout.write(chalk.gray(`Connecting...`));
49+
if (!raw) process.stdout.write(chalk.gray(`Waiting for logs...`));
4650

4751
es.onopen = () => {
4852
if (!raw) {
4953
process.stdout.cursorTo(0);
5054
process.stdout.clearLine();
51-
process.stdout.write(`${chalk.green('Connected!')} ${chalk.gray('Receiving data ...')}\n`);
55+
process.stdout.write(`${chalk.green('Connected!')} ${chalk.gray('Receiving logs ...')}\n`);
5256
}
5357
};
5458

5559
es.onerror = () => {
5660
process.stderr.write('\x1B[?25h'); //show terminal cursor
57-
console.error('Log-Stream error occurred. Retry...');
5861
};
5962
es.onmessage = e => {
6063
if (raw && e.data && e.data !== '{}') return console.log(e.data);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dropstack-cli",
3-
"version": "2.7.1",
3+
"version": "2.7.2",
44
"description": "A CLI to simplify continuous deployments into hybrid clouds.",
55
"author": "Mike Bild <mike@codecommission.com>",
66
"homepage": "https://github.com/codecommission/dropstack-cli#readme",

0 commit comments

Comments
 (0)