Chore: Removes some unneeded console logging and changes logs to errors (#26235)

This commit is contained in:
kay delaney 2020-07-10 15:07:04 +01:00 committed by GitHub
parent 718d6fb25d
commit 1391575853
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
51 changed files with 45 additions and 77 deletions

View File

@ -75,7 +75,7 @@ export function arrowTableToDataFrame(table: Table): ArrowDataFrame {
break;
}
default:
console.log('UNKNOWN Type:', schema);
console.error('UNKNOWN Type:', schema);
}
fields.push({

View File

@ -22,7 +22,7 @@ export function sanitize(unsanitizedString: string): string {
try {
return sanitizeXSS.process(unsanitizedString);
} catch (error) {
console.log('String could not be sanitized', unsanitizedString);
console.error('String could not be sanitized', unsanitizedString);
return unsanitizedString;
}
}

View File

@ -99,7 +99,7 @@ const patternToRegex = (pattern?: string): RegExp | undefined => {
try {
return stringToJsRegex(pattern);
} catch (error) {
console.log(error);
console.error(error);
return undefined;
}
};

View File

@ -180,7 +180,7 @@ export class Gauge extends PureComponent<Props> {
try {
$.plot(this.canvasElement, [plotSeries], options);
} catch (err) {
console.log('Gauge rendering error', err, options, value);
console.error('Gauge rendering error', err, options, value);
}
}

View File

@ -355,7 +355,7 @@ export class Graph extends PureComponent<GraphProps, GraphState> {
flotOptions
);
} catch (err) {
console.log('Graph rendering error', err, flotOptions, series);
console.error('Graph rendering error', err, flotOptions, series);
throw new Error('Error rendering panel');
}
}

View File

@ -13,7 +13,6 @@ class UnthemedCodeEditor extends React.PureComponent<Props> {
componentWillUnmount() {
if (this.completionCancel) {
console.log('dispose of the custom completion stuff');
this.completionCancel.dispose();
}
}

View File

@ -18,7 +18,6 @@ export const basic = () => {
height={'90vh'}
text={'a,b,c\n1,2,3'}
onSeriesParsed={(data: DataFrame[], text: string) => {
console.log('Data', data, text);
action('Data')(data, text);
}}
/>

View File

@ -38,10 +38,6 @@ export default class UiFindInput extends React.PureComponent<Props> {
this.props.onChange('');
};
componentWillUnmount(): void {
console.log('unomuet');
}
render() {
const { allowClear, inputProps, value } = this.props;

View File

@ -69,7 +69,7 @@ export class LoginCtrl extends PureComponent<Props, State> {
.then(() => {
this.toGrafana();
})
.catch((err: any) => console.log(err));
.catch((err: any) => console.error(err));
}
const resetModel = {

View File

@ -85,7 +85,7 @@ export class FilterByNameTransformerEditor extends React.PureComponent<
}
}
} catch (error) {
console.log(error);
console.error(error);
}
}

View File

@ -19,7 +19,6 @@ export function geminiScrollbar() {
let scrollRoot = elem.parent();
const scroller = elem;
console.log('scroll');
if (attrs.grafanaScrollbar && attrs.grafanaScrollbar === 'scrollonroot') {
scrollRoot = scroller;
}

View File

@ -15,7 +15,7 @@ export class SignUpCtrl {
// validate email is semi ok
if (params.email && !params.email.match(/^\S+@\S+$/)) {
console.log('invalid email');
console.error('invalid email');
return;
}

View File

@ -27,11 +27,9 @@ export class LiveSrv {
}
this.initPromise = new Promise((resolve, reject) => {
console.log('Live: connecting...');
this.conn = new WebSocket(this.getWebSocketUrl());
this.conn.onclose = (evt: any) => {
console.log('Live: websocket onclose', evt);
reject({ message: 'Connection closed' });
this.initPromise = null;
@ -45,11 +43,9 @@ export class LiveSrv {
this.conn.onerror = (evt: any) => {
this.initPromise = null;
reject({ message: 'Connection error' });
console.log('Live: websocket error', evt);
};
this.conn.onopen = (evt: any) => {
console.log('opened');
this.initPromise = null;
resolve(this.conn);
};
@ -62,7 +58,7 @@ export class LiveSrv {
message = JSON.parse(message);
if (!message.stream) {
console.log('Error: stream message without stream!', message);
console.error('Error: stream message without stream!', message);
return;
}
@ -81,8 +77,6 @@ export class LiveSrv {
return;
}
console.log('LiveSrv: Reconnecting');
this.getConnection().then((conn: any) => {
_.each(this.observers, (value, key) => {
this.send({ action: 'subscribe', stream: key });
@ -103,7 +97,6 @@ export class LiveSrv {
}
removeObserver(stream: any, observer: any) {
console.log('unsubscribe', stream);
delete this.observers[stream];
this.getConnection().then((conn: any) => {
@ -112,8 +105,6 @@ export class LiveSrv {
}
subscribe(streamName: string) {
console.log('LiveSrv.subscribe: ' + streamName);
return Observable.create((observer: any) => {
this.addObserver(streamName, observer);

View File

@ -4,7 +4,7 @@ export class AlertSrv {
constructor() {}
set() {
console.log('old depricated alert srv being used');
console.warn('old deprecated alert srv being used');
}
}

View File

@ -80,8 +80,6 @@ export class BridgeSrv {
this.$location.replace();
}
});
console.log('store updating angular $location.url', url);
}
// Check for template variable changes on a dashboard

View File

@ -34,7 +34,7 @@ export class PerformanceBackend implements EchoBackend<PerformanceEvent, Perform
metrics: this.buffer,
};
// Currently we don have API for sending the metrics hence loging to console in dev environment
// Currently we don't have an API for sending the metrics hence logging to console in dev environment
if (process.env.NODE_ENV === 'development') {
console.log('PerformanceBackend flushing:', result);
}

View File

@ -172,7 +172,7 @@ export class UserProvider extends PureComponent<Props, State> {
await getBackendSrv()
.put('/api/user', payload)
.then(this.loadUser)
.catch(e => console.log(e))
.catch(e => console.error(e))
.finally(() => {
this.setState({ loadingStates: { ...this.state.loadingStates, updateUserProfile: false } });
});

View File

@ -23,7 +23,7 @@ export class Emitter {
emit<T>(event: AppEvent<T>, payload: T): void;
emit<T>(event: AppEvent<T> | string, payload?: T | any): void {
if (typeof event === 'string') {
console.log(`Using strings as events is deprecated and will be removed in a future version. (${event})`);
console.warn(`Using strings as events is deprecated and will be removed in a future version. (${event})`);
this.emitter.emit(event, payload);
} else {
this.emitter.emit(event.name, payload);
@ -47,7 +47,7 @@ export class Emitter {
on<T>(event: AppEvent<T>, handler: (payload: T) => void, scope?: any): void;
on<T>(event: AppEvent<T> | string, handler: (payload?: T | any) => void, scope?: any) {
if (typeof event === 'string') {
console.log(`Using strings as events is deprecated and will be removed in a future version. (${event})`);
console.warn(`Using strings as events is deprecated and will be removed in a future version. (${event})`);
this.emitter.on(event, handler);
if (scope) {
@ -83,7 +83,7 @@ export class Emitter {
off<T>(event: AppEvent<T>, handler: (payload: T) => void): void;
off<T>(event: AppEvent<T> | string, handler: (payload?: T | any) => void) {
if (typeof event === 'string') {
console.log(`Using strings as events is deprecated and will be removed in a future version. (${event})`);
console.warn(`Using strings as events is deprecated and will be removed in a future version. (${event})`);
this.emitter.off(event, handler);
return;
}

View File

@ -19,7 +19,6 @@ export class LdapSyncInfo extends PureComponent<Props, State> {
};
handleSyncClick = () => {
console.log('Bulk-sync now');
this.setState({ isSyncing: !this.state.isSyncing });
};

View File

@ -37,7 +37,7 @@ export function loadAdminUserPage(userId: number): ThunkResult<void> {
}
dispatch(userAdminPageLoadedAction(true));
} catch (error) {
console.log(error);
console.error(error);
const userError = {
title: error.data.message,

View File

@ -62,7 +62,7 @@ export class AnnotationsSrv {
if (!err.message && err.data && err.data.message) {
err.message = err.data.message;
}
console.log('AnnotationSrv.query error', err);
console.error('AnnotationSrv.query error', err);
appEvents.emit(AppEvents.alertError, ['Annotation Query Failed', err.message || err]);
return [];
});

View File

@ -204,7 +204,7 @@ export class DashboardExporter {
return newObj;
})
.catch(err => {
console.log('Export failed:', err);
console.error('Export failed:', err);
return {
error: err,
};

View File

@ -109,7 +109,7 @@ export class InspectJSONTab extends PureComponent<Props, State> {
appEvents.emit(AppEvents.alertSuccess, ['Panel model updated']);
}
} catch (err) {
console.log('Error applyign updates', err);
console.error('Error applying updates', err);
appEvents.emit(AppEvents.alertError, ['Invalid JSON text']);
}

View File

@ -171,7 +171,6 @@ export class PanelChrome extends PureComponent<Props, State> {
onRefresh = () => {
const { panel, isInView, width } = this.props;
if (!isInView) {
console.log('Refresh when panel is visible', panel.id);
this.setState({ refreshWhenInView: true });
return;
}
@ -181,7 +180,6 @@ export class PanelChrome extends PureComponent<Props, State> {
// Issue Query
if (this.wantsQueryExecution) {
if (width < 0) {
console.log('Refresh skippted, no width yet... wait till we know');
return;
}

View File

@ -90,7 +90,7 @@ export class DashboardLoaderSrv {
};
},
(err: any) => {
console.log('Script dashboard error ' + err);
console.error('Script dashboard error ' + err);
this.$rootScope.appEvent(AppEvents.alertError, [
'Script Error',
'Please make sure it exists and returns a valid dashboard',

View File

@ -177,7 +177,7 @@ export class PanelQueryRunner {
this.pipeToSubject(runRequest(ds, request));
} catch (err) {
console.log('PanelQueryRunner Error', err);
console.error('PanelQueryRunner Error', err);
}
}

View File

@ -117,7 +117,7 @@ async function fetchDashboard(
}
} catch (err) {
dispatch(dashboardInitFailed({ message: 'Failed to fetch dashboard', error: err }));
console.log(err);
console.error(err);
return null;
}
}
@ -161,7 +161,7 @@ export function initDashboard(args: InitDashboardArgs): ThunkResult<void> {
dashboard = new DashboardModel(dashDTO.dashboard, dashDTO.meta);
} catch (err) {
dispatch(dashboardInitFailed({ message: 'Failed create dashboard model', error: err }));
console.log(err);
console.error(err);
return;
}
@ -216,7 +216,7 @@ export function initDashboard(args: InitDashboardArgs): ThunkResult<void> {
keybindingSrv.setupDashboardBindings(args.$scope, dashboard);
} catch (err) {
dispatch(notifyApp(createErrorNotification('Dashboard init failed', err)));
console.log(err);
console.error(err);
}
if (storeState.dashboard.modifiedQueries) {

View File

@ -116,7 +116,7 @@ export function runRequest(datasource: DataSourceApi, request: DataQueryRequest)
}),
// handle errors
catchError(err => {
console.log('runRequest.catchError', err);
console.error('runRequest.catchError', err);
return of({
...state.panelData,
state: LoadingState.Error,

View File

@ -66,7 +66,7 @@ export const refreshPanel = (panel: PanelModel) => {
};
export const toggleLegend = (panel: PanelModel) => {
console.log('Toggle legend is not implemented yet');
console.warn('Toggle legend is not implemented yet');
// We need to set panel.legend defaults first
// panel.legend.show = !panel.legend.show;
refreshPanel(panel);

View File

@ -67,7 +67,7 @@ export const initDataSourceSettings = (
dispatch(initDataSourceSettingsSucceeded(importedPlugin));
} catch (err) {
console.log('Failed to import plugin module', err);
console.error('Failed to import plugin module', err);
dispatch(initDataSourceSettingsFailed(err));
}
};

View File

@ -76,10 +76,6 @@ export class QueryRow extends PureComponent<QueryRowProps, QueryRowState> {
}
};
componentWillUnmount() {
console.log('QueryRow will unmount');
}
onClickToggleDisabled = () => {
const { exploreId, index, query } = this.props;
const newQuery = {

View File

@ -372,7 +372,7 @@ export const loadDatasource = (exploreId: ExploreId, instance: DataSourceApi, or
try {
instance.init();
} catch (err) {
console.log(err);
console.error(err);
}
}

View File

@ -30,7 +30,7 @@ export function uploadDashboardDirective(timer: any, $location: ILocationService
try {
dash = JSON.parse(e.target.result);
} catch (err) {
console.log(err);
console.error(err);
appEvents.emit(AppEvents.alertError, [
'Import failed',
'JSON -> JS Serialization failed: ' + err.message,

View File

@ -266,7 +266,7 @@ function pluginDirectiveLoader(
registerPluginComponent(scope, elem, attrs, componentInfo);
})
.catch((err: any) => {
console.log('Plugin component error', err);
console.error('Plugin component error', err);
});
},
};

View File

@ -561,7 +561,7 @@ export const initVariablesTransaction = (dashboardUid: string, dashboard: Dashbo
dispatch(variablesCompleteTransaction({ uid: dashboardUid }));
} catch (err) {
dispatch(notifyApp(createErrorNotification('Templating init failed', err)));
console.log(err);
console.error(err);
}
};

View File

@ -55,7 +55,6 @@ export function runSharedRequest(options: QueryRunnerOptions): Observable<PanelD
}
return () => {
console.log('runSharedRequest unsubscribe');
subscription.unsubscribe();
};
});

View File

@ -315,7 +315,7 @@ export class ElasticDatasource extends DataSourceApi<ElasticsearchQuery, Elastic
return { status: 'success', message: 'Index OK. Time field name OK.' };
},
(err: any) => {
console.log(err);
console.error(err);
if (err.data && err.data.error) {
let message = angular.toJson(err.data.error);
if (err.data.error.reason) {

View File

@ -135,7 +135,6 @@ export default class KustoQueryField extends QueryField {
} else if (modelPrefix.match(/(database\(\"(\w+)\"\)\.(.+\b)?$)/i)) {
typeaheadContext = 'context-database-table';
const db = this.getDBFromDatabaseFunction(modelPrefix);
console.log(db);
suggestionGroups = this.getTableSuggestions(db);
prefix = prefix.replace('.', '');

View File

@ -467,8 +467,6 @@ export class AzureMonitorQueryCtrl extends QueryCtrl {
this.replace(this.target.azureMonitor.metricName)
)
.then((metadata: any) => {
console.log('Update metadata', metadata);
this.target.azureMonitor.aggregation = metadata.primaryAggType;
this.target.azureMonitor.timeGrain = 'auto';
this.target.azureMonitor.allowedTimeGrainsMs = this.convertTimeGrainsToMs(metadata.supportedTimeGrains || []);
@ -527,7 +525,6 @@ export class AzureMonitorQueryCtrl extends QueryCtrl {
}
azureMonitorAddDimensionFilter() {
console.log('Add dimension', this.target.azureMonitor);
this.target.azureMonitor.dimensionFilters.push({
dimension: '',
operator: 'eq',
@ -538,7 +535,6 @@ export class AzureMonitorQueryCtrl extends QueryCtrl {
azureMonitorRemoveDimensionFilter(index: number) {
this.target.azureMonitor.dimensionFilters.splice(index, 1);
this.refresh();
console.log('Remove dimension', index, this.target.azureMonitor);
}
/* Azure Log Analytics */

View File

@ -581,7 +581,7 @@ export class GraphiteDatasource extends DataSourceApi<GraphiteQuery, GraphiteOpt
return this.funcDefs;
})
.catch((err: any) => {
console.log('Fetching graphite functions error', err);
console.error('Fetching graphite functions error', err);
this.funcDefs = gfunc.getFuncDefs(this.graphiteVersion);
return this.funcDefs;
});

View File

@ -54,7 +54,7 @@ export default class GraphiteQuery {
try {
this.parseTargetRecursive(astNode, null);
} catch (err) {
console.log('error parsing target:', err.message);
console.error('error parsing target:', err.message);
this.error = err.message;
this.target.textEditor = true;
}

View File

@ -321,18 +321,18 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
.toPromise()
.then((res: DataQueryResponse) => {
if (!res || !res.data || res.state !== LoadingState.Done) {
console.log('InfluxDB Error', res);
console.error('InfluxDB Error', res);
return { status: 'error', message: 'Error reading InfluxDB' };
}
const first = res.data[0];
if (first && first.length) {
return { status: 'success', message: `${first.length} buckets found` };
}
console.log('InfluxDB Error', res);
console.error('InfluxDB Error', res);
return { status: 'error', message: 'Error reading buckets' };
})
.catch((err: any) => {
console.log('InfluxDB Error', err);
console.error('InfluxDB Error', err);
return { status: 'error', message: err.message };
});
}

View File

@ -263,7 +263,7 @@ export class InfluxQueryCtrl extends QueryCtrl {
try {
this.target.query = this.queryModel.render(false);
} catch (err) {
console.log('query render error');
console.error('query render error');
}
this.target.rawQuery = !this.target.rawQuery;
}

View File

@ -172,7 +172,7 @@ export class MssqlDatasource {
return { status: 'success', message: 'Database Connection OK' };
})
.catch((err: any) => {
console.log(err);
console.error(err);
if (err.data && err.data.message) {
return { status: 'error', message: err.data.message };
} else {

View File

@ -190,7 +190,7 @@ export class MysqlDatasource {
return { status: 'success', message: 'Database Connection OK' };
})
.catch((err: any) => {
console.log(err);
console.error(err);
if (err.data && err.data.message) {
return { status: 'error', message: err.data.message };
} else {

View File

@ -178,7 +178,7 @@ export class PostgresDatasource {
return { status: 'success', message: 'Database Connection OK' };
})
.catch((err: any) => {
console.log(err);
console.error(err);
if (err.data && err.data.message) {
return { status: 'error', message: err.data.message };
} else {

View File

@ -226,7 +226,7 @@ function sortSeriesByLabel(s1: TimeSeries, s2: TimeSeries): number {
le1 = parseHistogramLabel(s1.target);
le2 = parseHistogramLabel(s2.target);
} catch (err) {
console.log(err);
console.error(err);
return 0;
}

View File

@ -530,7 +530,7 @@ class GraphElement {
delete this.ctrl.error;
}
} catch (e) {
console.log('flotcharts error', e);
console.error('flotcharts error', e);
this.ctrl.error = e.message || 'Render Error';
this.ctrl.renderError = true;
}

View File

@ -253,7 +253,6 @@ export class GraphCtrl extends MetricsPanelCtrl {
tip: 'Data exists, but is not timeseries',
actionText: 'Switch to table view',
action: () => {
console.log('Change from graph to table');
dispatch(changePanelPlugin(this.panel, 'table'));
},
};

View File

@ -59,7 +59,7 @@ function sortSeriesByLabel(s1: { label: string }, s2: { label: string }) {
label1 = parseHistogramLabel(s1.label);
label2 = parseHistogramLabel(s2.label);
} catch (err) {
console.log(err.message || err);
console.error(err.message || err);
return 0;
}

View File

@ -101,7 +101,7 @@ export class GrafanaCtrl {
let callerScope = this;
if (callerScope.$id === 1 && !localScope) {
console.log('warning rootScope onAppEvent called without localscope');
console.warn('warning rootScope onAppEvent called without localscope');
}
if (localScope) {
callerScope = localScope;