Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,13 @@ Object {
},
Object {
"@timestamp": "## @timestamp ##",
"message": "registering route handler for [/core]",
"pid": "## PID ##",
"tags": Array [
"info",
"http",
],
"type": "log",
},
Object {
"@timestamp": "## @timestamp ##",
"message": "starting http server [localhost:8274]",
"message": "Server running at http://localhost:8274",
"pid": "## PID ##",
"tags": Array [
"info",
"http",
"server",
],
"type": "log",
},
Object {
"@timestamp": "## @timestamp ##",
"message": "Server running at http://localhost:8274",
"pid": "## PID ##",
"tags": Array [
"listening",
"info",
],
"type": "log",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ Object {

exports[`register route handler 1`] = `
Object {
"debug": Array [],
"error": Array [],
"fatal": Array [],
"info": Array [
"debug": Array [
Array [
"registering route handler for [/foo]",
],
],
"error": Array [],
"fatal": Array [],
"info": Array [],
"log": Array [],
"trace": Array [],
"warn": Array [],
Expand Down
8 changes: 6 additions & 2 deletions src/core/server/http/http_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ export class HttpServer {
});
}

this.log.info(`starting http server [${config.host}:${config.port}]`);

await this.server.start();

this.log.info(
`Server running at ${this.server.info.uri}${config.rewriteBasePath ? config.basePath : ''}`,
// The "legacy" Kibana will output log records with `listening` tag even if `quiet` logging mode is enabled.
{ tags: ['listening'] }
);
}

public async stop() {
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/http_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class HttpService implements CoreService {
'Router will **not** be applied.'
);
} else {
this.log.info(`registering route handler for [${router.path}]`);
this.log.debug(`registering route handler for [${router.path}]`);
Copy link
Member Author

Choose a reason for hiding this comment

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

note: we're going to register lots of routes in the future and logging every one with info level is probably too much...

this.httpServer.registerRouter(router);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,25 @@ Array [
"message-8-with-message",
2012-02-01T11:22:33.044Z,
],
Array [
Array [
"info",
"context-9",
"sub-context-9",
],
"message-9-with-message",
2012-02-01T11:22:33.044Z,
],
Array [
Array [
"info",
"context-10",
"sub-context-10",
"tag1",
"tag2",
],
"message-10-with-message",
2012-02-01T11:22:33.044Z,
],
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ test('`append()` correctly pushes records to legacy platform.', () => {
message: 'message-8-with-message',
timestamp,
},
{
context: 'context-9.sub-context-9',
level: LogLevel.Info,
message: 'message-9-with-message',
timestamp,
meta: { someValue: 3 },
},
{
context: 'context-10.sub-context-10',
level: LogLevel.Info,
message: 'message-10-with-message',
timestamp,
meta: { tags: ['tag1', 'tag2'] },
},
];

const rawKbnServerMock = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ export class LegacyAppender implements DisposableAppender {
* write record to the configured destination.
* @param record `LogRecord` instance to forward to.
*/
public append(record: LogRecord) {
this.kbnServer.log(
[record.level.id.toLowerCase(), ...record.context.split('.')],
record.error || record.message,
record.timestamp
);
public append({ level, context, message, error, timestamp, meta = {} }: LogRecord) {
const tags = [level.id.toLowerCase(), ...context.split('.'), ...(meta.tags || [])];
Copy link
Member Author

@azasypkin azasypkin Jul 12, 2018

Choose a reason for hiding this comment

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

note: we weren't passing meta to legacy platform previously since we didn't know whether we really need it, turned out we need custom tags like listening that can't be part of context.


this.kbnServer.log(tags, error || message, timestamp);
}

public async dispose() {
Expand Down
10 changes: 1 addition & 9 deletions src/server/kbn_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@ export default class KbnServer {
* @return undefined
*/
async listen() {
const {
server,
config,
} = this;
const { server } = this;

await this.ready();
await fromNode(cb => server.start(cb));
Expand All @@ -153,11 +150,6 @@ export default class KbnServer {
process.send(['WORKER_LISTENING']);
}

server.log(['listening', 'info'], `Server running at ${server.info.uri}${
config.get('server.rewriteBasePath')
? config.get('server.basePath')
: ''
}`);
return server;
}

Expand Down