Skip to content

Commit

Permalink
[Ingest] Use Kibana logger for proper server-side logging (elastic#66017
Browse files Browse the repository at this point in the history
) (elastic#66068)

* Add logger to app context.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
skh and elasticmachine committed May 12, 2020
1 parent 2f54528 commit 193f6f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions x-pack/plugins/ingest_manager/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { first } from 'rxjs/operators';
import {
CoreSetup,
CoreStart,
Logger,
Plugin,
PluginInitializerContext,
SavedObjectsServiceStart,
Expand Down Expand Up @@ -73,6 +74,7 @@ export interface IngestManagerAppContext {
isProductionMode: boolean;
kibanaVersion: string;
cloud?: CloudSetup;
logger?: Logger;
httpSetup?: HttpServiceSetup;
}

Expand Down Expand Up @@ -108,6 +110,7 @@ export class IngestManagerPlugin
private config$: Observable<IngestManagerConfigType>;
private security: SecurityPluginSetup | undefined;
private cloud: CloudSetup | undefined;
private logger: Logger | undefined;

private isProductionMode: boolean;
private kibanaVersion: string;
Expand All @@ -117,6 +120,7 @@ export class IngestManagerPlugin
this.config$ = this.initializerContext.config.create<IngestManagerConfigType>();
this.isProductionMode = this.initializerContext.env.mode.prod;
this.kibanaVersion = this.initializerContext.env.packageInfo.version;
this.logger = this.initializerContext.logger.get();
}

public async setup(core: CoreSetup, deps: IngestManagerSetupDeps) {
Expand Down Expand Up @@ -208,6 +212,7 @@ export class IngestManagerPlugin
kibanaVersion: this.kibanaVersion,
httpSetup: this.httpSetup,
cloud: this.cloud,
logger: this.logger,
});
licenseService.start(this.licensing$);
return {
Expand Down
8 changes: 7 additions & 1 deletion x-pack/plugins/ingest_manager/server/services/app_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import { BehaviorSubject, Observable } from 'rxjs';
import { first } from 'rxjs/operators';
import { SavedObjectsServiceStart, HttpServiceSetup } from 'src/core/server';
import { SavedObjectsServiceStart, HttpServiceSetup, Logger } from 'src/core/server';
import { EncryptedSavedObjectsPluginStart } from '../../../encrypted_saved_objects/server';
import { SecurityPluginSetup } from '../../../security/server';
import { IngestManagerConfigType } from '../../common';
Expand All @@ -21,6 +21,7 @@ class AppContextService {
private isProductionMode: boolean = false;
private kibanaVersion: string | undefined;
private cloud?: CloudSetup;
private logger?: Logger;
private httpSetup?: HttpServiceSetup;

public async start(appContext: IngestManagerAppContext) {
Expand All @@ -29,6 +30,7 @@ class AppContextService {
this.savedObjects = appContext.savedObjects;
this.isProductionMode = appContext.isProductionMode;
this.cloud = appContext.cloud;
this.logger = appContext.logger;
this.kibanaVersion = appContext.kibanaVersion;
this.httpSetup = appContext.httpSetup;

Expand Down Expand Up @@ -60,6 +62,10 @@ class AppContextService {
return this.cloud;
}

public getLogger() {
return this.logger;
}

public getConfig() {
return this.configSubject$?.value;
}
Expand Down

0 comments on commit 193f6f7

Please sign in to comment.