mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Improve EchoSrv logging (#76385)
* Chore: Allow frontend logging to be logged via localStorage * improve echo srv logging
This commit is contained in:
parent
2771fb9403
commit
46b0066644
@ -19,17 +19,22 @@ export interface Logger {
|
||||
|
||||
/** @internal */
|
||||
export const createLogger = (name: string): Logger => {
|
||||
let LOGGIN_ENABLED = false;
|
||||
let loggingEnabled = false;
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
loggingEnabled = window.localStorage.getItem('grafana.debug') === 'true';
|
||||
}
|
||||
|
||||
return {
|
||||
logger: (id: string, throttle = false, ...t: any[]) => {
|
||||
if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test' || !LOGGIN_ENABLED) {
|
||||
if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test' || !loggingEnabled) {
|
||||
return;
|
||||
}
|
||||
const fn = throttle ? throttledLog : console.log;
|
||||
fn(`[${name}: ${id}]: `, ...t);
|
||||
fn(`[${name}: ${id}]:`, ...t);
|
||||
},
|
||||
enable: () => (LOGGIN_ENABLED = true),
|
||||
disable: () => (LOGGIN_ENABLED = false),
|
||||
isEnabled: () => LOGGIN_ENABLED,
|
||||
enable: () => (loggingEnabled = true),
|
||||
disable: () => (loggingEnabled = false),
|
||||
isEnabled: () => loggingEnabled,
|
||||
};
|
||||
};
|
||||
|
@ -59,7 +59,11 @@ export class Echo implements EchoSrv {
|
||||
backend.addEvent(_event);
|
||||
}
|
||||
}
|
||||
echoLog('Reporting event', false, _event);
|
||||
|
||||
echoLog(`${event.type} event`, false, {
|
||||
...event.payload,
|
||||
meta: _event.meta,
|
||||
});
|
||||
};
|
||||
|
||||
getMeta = (): EchoMeta => {
|
||||
|
Loading…
Reference in New Issue
Block a user