mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
This commit is contained in:
parent
7f8b424e2f
commit
8ff7ea0b1e
6 changed files with 44 additions and 24 deletions
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export let mlLog = () => {};
|
||||
|
||||
export function initMlServerLog(log) {
|
||||
mlLog = (level, message) => log(['ml', level], message);
|
||||
}
|
33
x-pack/plugins/ml/server/client/log.ts
Normal file
33
x-pack/plugins/ml/server/client/log.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { Logger } from '../../../../../src/core/server';
|
||||
|
||||
export interface LogInitialization {
|
||||
log: Logger;
|
||||
}
|
||||
|
||||
interface MlLog {
|
||||
fatal: (message: string) => void;
|
||||
error: (message: string) => void;
|
||||
warn: (message: string) => void;
|
||||
info: (message: string) => void;
|
||||
debug: (message: string) => void;
|
||||
trace: (message: string) => void;
|
||||
}
|
||||
|
||||
export let mlLog: MlLog;
|
||||
|
||||
export function initMlServerLog(logInitialization: LogInitialization) {
|
||||
mlLog = {
|
||||
fatal: (message: string) => logInitialization.log.fatal(message),
|
||||
error: (message: string) => logInitialization.log.error(message),
|
||||
warn: (message: string) => logInitialization.log.warn(message),
|
||||
info: (message: string) => logInitialization.log.info(message),
|
||||
debug: (message: string) => logInitialization.log.debug(message),
|
||||
trace: (message: string) => logInitialization.log.trace(message),
|
||||
};
|
||||
}
|
|
@ -40,7 +40,7 @@ export async function isAnnotationsFeatureAvailable(callWithRequest) {
|
|||
if (!annotationsWriteAliasExists) return false;
|
||||
|
||||
} catch (err) {
|
||||
mlLog('info', 'Disabling ML annotations feature because the index/alias integrity check failed.');
|
||||
mlLog.info('Disabling ML annotations feature because the index/alias integrity check failed.');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ export class DataRecognizer {
|
|||
try {
|
||||
file = await this.readFile(`${this.modulesDir}/${dir}/manifest.json`);
|
||||
} catch (error) {
|
||||
mlLog('warning', `Data recognizer skipping folder ${dir} as manifest.json cannot be read`);
|
||||
mlLog.warn(`Data recognizer skipping folder ${dir} as manifest.json cannot be read`);
|
||||
}
|
||||
|
||||
if (file !== undefined) {
|
||||
|
@ -78,7 +78,7 @@ export class DataRecognizer {
|
|||
json: JSON.parse(file)
|
||||
});
|
||||
} catch (error) {
|
||||
mlLog('warning', `Data recognizer error parsing ${dir}/manifest.json. ${error}`);
|
||||
mlLog.warn(`Data recognizer error parsing ${dir}/manifest.json. ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ export class DataRecognizer {
|
|||
try {
|
||||
match = await this.searchForFields(moduleConfig, indexPattern);
|
||||
} catch (error) {
|
||||
mlLog('warning', `Data recognizer error running query defined for module ${moduleConfig.id}. ${error}`);
|
||||
mlLog.warn(`Data recognizer error running query defined for module ${moduleConfig.id}. ${error}`);
|
||||
}
|
||||
|
||||
if (match === true) {
|
||||
|
@ -194,7 +194,7 @@ export class DataRecognizer {
|
|||
config: JSON.parse(jobConfig)
|
||||
});
|
||||
} catch (error) {
|
||||
mlLog('warning', `Data recognizer error loading config for job ${job.id} for module ${id}. ${error}`);
|
||||
mlLog.warn(`Data recognizer error loading config for job ${job.id} for module ${id}. ${error}`);
|
||||
}
|
||||
}));
|
||||
|
||||
|
@ -211,7 +211,7 @@ export class DataRecognizer {
|
|||
config
|
||||
});
|
||||
} catch (error) {
|
||||
mlLog('warning', `Data recognizer error loading config for datafeed ${datafeed.id} for module ${id}. ${error}`);
|
||||
mlLog.warn(`Data recognizer error loading config for datafeed ${datafeed.id} for module ${id}. ${error}`);
|
||||
}
|
||||
}));
|
||||
|
||||
|
@ -232,7 +232,7 @@ export class DataRecognizer {
|
|||
config
|
||||
});
|
||||
} catch (error) {
|
||||
mlLog('warning', `Data recognizer error loading config for ${key} ${obj.id} for module ${id}. ${error}`);
|
||||
mlLog.warn(`Data recognizer error loading config for ${key} ${obj.id} for module ${id}. ${error}`);
|
||||
}
|
||||
}));
|
||||
}));
|
||||
|
|
|
@ -57,7 +57,7 @@ import { jobAuditMessagesRoutes } from '../routes/job_audit_messages';
|
|||
// @ts-ignore: could not find declaration file for module
|
||||
import { fileDataVisualizerRoutes } from '../routes/file_data_visualizer';
|
||||
// @ts-ignore: could not find declaration file for module
|
||||
import { initMlServerLog } from '../client/log';
|
||||
import { initMlServerLog, LogInitialization } from '../client/log';
|
||||
|
||||
export interface MlHttpServiceSetup extends HttpServiceSetup {
|
||||
route(route: ServerRoute | ServerRoute[]): void;
|
||||
|
@ -108,9 +108,7 @@ export interface UsageInitialization {
|
|||
};
|
||||
savedObjects: SavedObjectsService;
|
||||
}
|
||||
export interface LogInitialization {
|
||||
log: Logger;
|
||||
}
|
||||
|
||||
export class Plugin {
|
||||
private readonly pluginId: string = 'ml';
|
||||
private config: any;
|
||||
|
|
|
@ -54,9 +54,9 @@ export function systemRoutes({ commonRouteConfig, elasticsearchPlugin, route, xp
|
|||
// most likely they do not have the ml_user role and therefore will be blocked from using
|
||||
// ML at all. However, we need to catch this error so the privilege check doesn't fail.
|
||||
if (error.status === 403) {
|
||||
mlLog('info', 'Unable to determine whether upgrade is being performed due to insufficient user privileges');
|
||||
mlLog.info('Unable to determine whether upgrade is being performed due to insufficient user privileges');
|
||||
} else {
|
||||
mlLog('warning', 'Unable to determine whether upgrade is being performed');
|
||||
mlLog.warn('Unable to determine whether upgrade is being performed');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue