mirror of
https://github.com/Lissy93/dashy.git
synced 2025-07-26 23:24:38 +02:00
⚡ Improved error logging
This commit is contained in:
parent
09bc8a32f3
commit
a66636bde8
@ -1,14 +1,19 @@
|
|||||||
/* eslint no-console: ["error", { allow: ["log"] }] */
|
/* eslint no-console: ["error", { allow: ["log", "info"] }] */
|
||||||
|
|
||||||
export const welcomeMsg = () => {
|
export const welcomeMsg = () => {
|
||||||
const v = process.env.VUE_APP_VERSION ? `V${process.env.VUE_APP_VERSION}` : '';
|
const v = process.env.VUE_APP_VERSION ? `V${process.env.VUE_APP_VERSION}` : '';
|
||||||
console.log(`%cDashy ${v} 🚀`, 'color:#00af87; background:#0b1021; font-size:36px; padding: 0.5rem 0.5rem 0; margin: 1rem auto; font-family: Rockwell; border: 2px solid #00af87; border-radius: 4px;font-weight: bold; text-shadow: 1px 1px 1px #00af87bf;');
|
console.log(`%cDashy ${v} 🚀`, 'color:#00af87; background:#0b1021; font-size:1.5rem; padding: 0 0.5rem 0; margin: 1rem auto; font-family: Rockwell; border: 2px solid #00af87; border-radius: 4px;font-weight: bold; text-shadow: 1px 1px 1px #00af87bf;');
|
||||||
};
|
};
|
||||||
|
|
||||||
export const warningMsg = () => {
|
export const warningMsg = (message) => {
|
||||||
console.log('%c⚠️ Error ⚠️', "background:#21bbca; color:#0b1021; font-size:20px; padding:0.25rem 0.5rem; margin: 1rem auto 0.25rem; font-family: 'Trebuchet MS', Helvetica; border: 2px solid yellow; border-radius: 4px; font-weight: bold;");
|
console.info(
|
||||||
|
`%c⚠️ Warning ⚠️%c \n${message} \n\n%c🐛If you have found a bug, please open a ticket on GitHub, at: https://git.io/JukXk`,
|
||||||
|
"color:#ceb73f; background: #ceb73f33; font-size:1.2rem; padding:0.15rem; margin: 0.2rem auto 1rem auto; font-family: Rockwell, Tahoma, 'Trebuchet MS', Helvetica; border: 2px solid #ceb73f; border-radius: 4px; font-weight: bold; text-shadow: 1px 1px 1px #000000bf;",
|
||||||
|
'font-weight: bold; font-size: 0.9rem;color: #ceb73f;',
|
||||||
|
"color: #ceb73f; font-size: 0.6rem; font-family: Tahoma, 'Trebuchet MS', Helvetica;",
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const raiseBug = () => {
|
export const raiseBug = () => {
|
||||||
console.log('%c🐛If you have found a bug, raise an issue on GitHub, at:\nhttps://git.io/JnqPR', "color:#dddd10; font-size: 14px; font-family: 'Trebuchet MS', Helvetica;");
|
console.log('%c🐛If you have found a bug, raise an issue on GitHub, at:\nhttps://git.io/JukXk', "color:#dddd10; font-size: 14px; font-family: 'Trebuchet MS', Helvetica;");
|
||||||
};
|
};
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
/* eslint no-console: ["error", { allow: ["warn", "error"] }] */
|
/* eslint no-console: ["error", { allow: ["warn", "error"] }] */
|
||||||
|
import * as Sentry from '@sentry/vue';
|
||||||
import { warningMsg, raiseBug } from '@/utils/CoolConsole';
|
import { warningMsg } from '@/utils/CoolConsole';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called when an error happens
|
* Function called when an error happens
|
||||||
* If you wish to use an error logging service, put code for it here
|
* If you wish to use an error logging service, put code for it here
|
||||||
*/
|
*/
|
||||||
const ErrorHandler = function handler(msg) {
|
const ErrorHandler = function handler(msg) {
|
||||||
warningMsg();
|
warningMsg(msg);
|
||||||
console.warn(msg);
|
Sentry.captureMessage(msg);
|
||||||
raiseBug();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ErrorHandler;
|
export default ErrorHandler;
|
||||||
|
@ -12,11 +12,13 @@
|
|||||||
import ConfigAccumulator from '@/utils/ConfigAccumalator';
|
import ConfigAccumulator from '@/utils/ConfigAccumalator';
|
||||||
import { sentryDsn } from '@/utils/defaults';
|
import { sentryDsn } from '@/utils/defaults';
|
||||||
|
|
||||||
const ErrorTracking = (Vue, router) => {
|
const ErrorReporting = (Vue, router) => {
|
||||||
// Fetch users config
|
// Fetch users config
|
||||||
const appConfig = new ConfigAccumulator().appConfig() || {};
|
const appConfig = new ConfigAccumulator().appConfig() || {};
|
||||||
// Check if error reporting is enabled. Only proceed if user has turned it on.
|
// Check if error reporting is enabled. Only proceed if user has turned it on.
|
||||||
if (appConfig.enableErrorReporting) {
|
if (appConfig.enableErrorReporting) {
|
||||||
|
// Get current app version
|
||||||
|
const appVersion = process.env.VUE_APP_VERSION ? `Dashy@${process.env.VUE_APP_VERSION}` : '';
|
||||||
// Import Sentry
|
// Import Sentry
|
||||||
const Sentry = require('@sentry/vue');
|
const Sentry = require('@sentry/vue');
|
||||||
const { Integrations } = require('@sentry/tracing');
|
const { Integrations } = require('@sentry/tracing');
|
||||||
@ -32,10 +34,11 @@ const ErrorTracking = (Vue, router) => {
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
tracesSampleRate: 1.0,
|
tracesSampleRate: 1.0,
|
||||||
|
release: appVersion,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Error reporting not enabled. Do Nothing.
|
// Error reporting has not been enabled by the user. Do Nothing.
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ErrorTracking;
|
export default ErrorReporting;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user