Improved error logging

This commit is contained in:
Alicia Sykes 2021-09-04 23:09:21 +01:00
parent 09bc8a32f3
commit a66636bde8
3 changed files with 20 additions and 13 deletions

View File

@ -1,14 +1,19 @@
/* eslint no-console: ["error", { allow: ["log"] }] */
/* eslint no-console: ["error", { allow: ["log", "info"] }] */
export const welcomeMsg = () => {
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 = () => {
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;");
export const warningMsg = (message) => {
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 = () => {
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;");
};

View File

@ -1,15 +1,14 @@
/* eslint no-console: ["error", { allow: ["warn", "error"] }] */
import { warningMsg, raiseBug } from '@/utils/CoolConsole';
import * as Sentry from '@sentry/vue';
import { warningMsg } from '@/utils/CoolConsole';
/**
* Function called when an error happens
* If you wish to use an error logging service, put code for it here
*/
const ErrorHandler = function handler(msg) {
warningMsg();
console.warn(msg);
raiseBug();
warningMsg(msg);
Sentry.captureMessage(msg);
};
export default ErrorHandler;

View File

@ -12,11 +12,13 @@
import ConfigAccumulator from '@/utils/ConfigAccumalator';
import { sentryDsn } from '@/utils/defaults';
const ErrorTracking = (Vue, router) => {
const ErrorReporting = (Vue, router) => {
// Fetch users config
const appConfig = new ConfigAccumulator().appConfig() || {};
// Check if error reporting is enabled. Only proceed if user has turned it on.
if (appConfig.enableErrorReporting) {
// Get current app version
const appVersion = process.env.VUE_APP_VERSION ? `Dashy@${process.env.VUE_APP_VERSION}` : '';
// Import Sentry
const Sentry = require('@sentry/vue');
const { Integrations } = require('@sentry/tracing');
@ -32,10 +34,11 @@ const ErrorTracking = (Vue, router) => {
}),
],
tracesSampleRate: 1.0,
release: appVersion,
});
} else {
// Error reporting not enabled. Do Nothing.
// Error reporting has not been enabled by the user. Do Nothing.
}
};
export default ErrorTracking;
export default ErrorReporting;