Skip to content

Printing process warning's via the appropriate loggers #8746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/kibana
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ if [ ! -x "$NODE" ]; then
exit 1
fi

exec "${NODE}" $NODE_OPTIONS "${DIR}/src/cli" ${@}
exec "${NODE}" $NODE_OPTIONS --no-warnings "${DIR}/src/cli" ${@}
Copy link
Contributor Author

@kobelb kobelb Oct 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't been able to find a way to selectively add this flag, besides potentially determining if the --dev flag is provided.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding the flag all the time is fine, since we are forwarding all the messages via the server logger.

2 changes: 1 addition & 1 deletion bin/kibana-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ if [ ! -x "$NODE" ]; then
exit 1
fi

exec "${NODE}" $NODE_OPTIONS "${DIR}/src/cli_plugin" ${@}
exec "${NODE}" $NODE_OPTIONS --no-warnings "${DIR}/src/cli_plugin" ${@}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The kibana-plugin is currently not displaying the warnings at all, currently investigating the best way to determine if "we're in production"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cli plugin command has it's own logger with it's own opinions about when messages should and shouldn't be logged (controlled with --silent and --quiet) https://github.com/elastic/kibana/blob/master/src/cli_plugin/lib/logger.js

We should probably wire this up in that cli

2 changes: 1 addition & 1 deletion bin/kibana-plugin.bat
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ If Not Exist "%NODE%" (
)

TITLE Kibana Server
"%NODE%" %NODE_OPTIONS% "%DIR%\src\cli_plugin" %*
"%NODE%" %NODE_OPTIONS% --no-warnings "%DIR%\src\cli_plugin" %*

:finally

Expand Down
2 changes: 1 addition & 1 deletion bin/kibana.bat
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ If Not Exist "%NODE%" (
)

TITLE Kibana Server
"%NODE%" %NODE_OPTIONS% "%DIR%\src\cli" %*
"%NODE%" %NODE_OPTIONS% --no-warnings "%DIR%\src\cli" %*

:finally

Expand Down
2 changes: 2 additions & 0 deletions src/cli_plugin/install/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import pkg from '../../utils/package_json';
import { getConfig } from '../../server/path';
import { parse, parseMilliseconds } from './settings';
import { find } from 'lodash';
import logWarnings from '../lib/log_warnings';

function processCommand(command, options) {
let settings;
Expand All @@ -18,6 +19,7 @@ function processCommand(command, options) {
}

const logger = new Logger(settings);
logWarnings(settings, logger);
install(settings, logger);
}

Expand Down
5 changes: 5 additions & 0 deletions src/cli_plugin/lib/log_warnings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function (settings, logger) {
process.on('warning', (warning) => {
logger.error(warning);
});
}
2 changes: 2 additions & 0 deletions src/cli_plugin/list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { fromRoot } from '../../utils';
import list from './list';
import Logger from '../lib/logger';
import { parse } from './settings';
import logWarnings from '../lib/log_warnings';

function processCommand(command, options) {
let settings;
Expand All @@ -14,6 +15,7 @@ function processCommand(command, options) {
}

const logger = new Logger(settings);
logWarnings(settings, logger);
list(settings, logger);
}

Expand Down
2 changes: 2 additions & 0 deletions src/cli_plugin/remove/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import remove from './remove';
import Logger from '../lib/logger';
import { parse } from './settings';
import { getConfig } from '../../server/path';
import logWarnings from '../lib/log_warnings';

function processCommand(command, options) {
let settings;
Expand All @@ -15,6 +16,7 @@ function processCommand(command, options) {
}

const logger = new Logger(settings);
logWarnings(settings, logger);
remove(settings, logger);
}

Expand Down
1 change: 1 addition & 0 deletions src/server/kbn_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = class KbnServer {
require('./config/setup'), // sets this.config, reads this.settings
require('./http'), // sets this.server
require('./logging'),
require('./warnings'),
require('./status'),

// writes pid file
Expand Down
5 changes: 5 additions & 0 deletions src/server/warnings/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function (kbnServer, server, config) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming that we only have one instance of the kbnServer per 'process' (including when we're clustering) so we won't be subscribing to this event twice and possibly getting duplicate warnings.

Copy link
Contributor

@spalger spalger Oct 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming that we only have one instance of the kbnServer per 'process' (including when we're clustering) so we won't be subscribing to this event twice and possibly getting duplicate warnings.

Not necessarily, but I don't think there is a better option right now.

process.on('warning', (warning) => {
server.log(['warning', 'process'], warning);
});
}