mirror of https://github.com/rancher/dashboard.git
Remove console output from diagnostic page
- Follows on from - https://github.com/rancher/dashboard/pull/6603 - https://github.com/rancher/dashboard/pull/6700 - To track messages the console methods were overwritten - When the console methods were called, we would track message and then call the original console method - Output into the standard browser console window was broken though - the inline stack trace for all logs is the place where the original console method is called - this was always `console.js` - This causes issues whilst in development but also for logs coming from customers - Investigate ways around this, but couldn't find anything nice - short term solution is to remove the feature
This commit is contained in:
parent
3813e4bd8d
commit
f97025c647
|
|
@ -36,7 +36,6 @@ import '../plugins/global-formatters';
|
||||||
import '../plugins/trim-whitespace';
|
import '../plugins/trim-whitespace';
|
||||||
import '../plugins/extend-router';
|
import '../plugins/extend-router';
|
||||||
|
|
||||||
import consolePlugin from '../plugins/console';
|
|
||||||
import intNumber from '../plugins/int-number';
|
import intNumber from '../plugins/int-number';
|
||||||
import nuxtClientInit from '../plugins/nuxt-client-init';
|
import nuxtClientInit from '../plugins/nuxt-client-init';
|
||||||
import replaceAll from '../plugins/replaceall';
|
import replaceAll from '../plugins/replaceall';
|
||||||
|
|
@ -274,10 +273,6 @@ async function createApp(ssrContext, config = {}) {
|
||||||
await axiosShell(app.context, inject);
|
await axiosShell(app.context, inject);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.client && typeof consolePlugin === 'function') {
|
|
||||||
await consolePlugin(app.context, inject);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.client && typeof intNumber === 'function') {
|
if (process.client && typeof intNumber === 'function') {
|
||||||
await intNumber(app.context, inject);
|
await intNumber(app.context, inject);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,9 +120,6 @@ export default {
|
||||||
systemInformation.jsMemory.value += `, ${ this.t('about.diagnostic.systemInformation.memUsedJsHeapSize', { usedJSHeapSize: window?.performance?.memory?.usedJSHeapSize }) }`;
|
systemInformation.jsMemory.value += `, ${ this.t('about.diagnostic.systemInformation.memUsedJsHeapSize', { usedJSHeapSize: window?.performance?.memory?.usedJSHeapSize }) }`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// scroll logs container to the bottom
|
|
||||||
this.scrollLogsToBottom();
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
systemInformation,
|
systemInformation,
|
||||||
topFifteenForResponseTime: null,
|
topFifteenForResponseTime: null,
|
||||||
|
|
@ -130,16 +127,9 @@ export default {
|
||||||
finalCounts: null,
|
finalCounts: null,
|
||||||
includeResponseTimes: true,
|
includeResponseTimes: true,
|
||||||
storeMapping: this.$store?._modules?.root?.state,
|
storeMapping: this.$store?._modules?.root?.state,
|
||||||
latestLogs: console.logs // eslint-disable-line no-console
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
|
||||||
latestLogs() {
|
|
||||||
this.scrollLogsToBottom();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
clusterCount() {
|
clusterCount() {
|
||||||
return this.finalCounts?.length;
|
return this.finalCounts?.length;
|
||||||
|
|
@ -147,14 +137,6 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
scrollLogsToBottom() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
const logsContainer = document.querySelector('.logs-container');
|
|
||||||
|
|
||||||
logsContainer.scrollTop = logsContainer.scrollHeight;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
generateKey(data) {
|
generateKey(data) {
|
||||||
const randomize = Math.random() * 10000;
|
const randomize = Math.random() * 10000;
|
||||||
|
|
||||||
|
|
@ -166,7 +148,6 @@ export default {
|
||||||
const fileName = 'rancher-diagnostic-data.json';
|
const fileName = 'rancher-diagnostic-data.json';
|
||||||
const data = {
|
const data = {
|
||||||
systemInformation: this.systemInformation,
|
systemInformation: this.systemInformation,
|
||||||
logs: this.latestLogs,
|
|
||||||
storeMapping: this.parseStoreData(this.storeMapping),
|
storeMapping: this.parseStoreData(this.storeMapping),
|
||||||
resourceCounts: this.finalCounts,
|
resourceCounts: this.finalCounts,
|
||||||
responseTimes: this.responseTimes
|
responseTimes: this.responseTimes
|
||||||
|
|
@ -411,26 +392,6 @@ export default {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Logs -->
|
|
||||||
<div class="mb-40">
|
|
||||||
<h2 class="mb-20">
|
|
||||||
{{ t('about.diagnostic.logs.subtitle') }}
|
|
||||||
</h2>
|
|
||||||
<ul class="logs-container">
|
|
||||||
<li
|
|
||||||
v-for="logEntry in latestLogs"
|
|
||||||
:key="generateKey(logEntry.timestamp)"
|
|
||||||
:class="logEntry.type"
|
|
||||||
>
|
|
||||||
<span class="log-entry-type">{{ logEntry.type }} :: </span>
|
|
||||||
<span
|
|
||||||
v-for="(arg, i) in logEntry.data"
|
|
||||||
:key="i"
|
|
||||||
>{{ arg }}</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<PromptModal />
|
<PromptModal />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
/* eslint-disable no-console */
|
|
||||||
export default () => {
|
|
||||||
const logTypes = ['warn', 'error'];
|
|
||||||
const MAX_LOGS_STORED = 400;
|
|
||||||
|
|
||||||
if (!process.env.dev) {
|
|
||||||
console.logLog = console.log.bind(console);
|
|
||||||
console.infoLog = console.info.bind(console);
|
|
||||||
logTypes.push('log');
|
|
||||||
logTypes.push('info');
|
|
||||||
}
|
|
||||||
|
|
||||||
console.warnLog = console.warn.bind(console);
|
|
||||||
console.errorLog = console.error.bind(console);
|
|
||||||
console.logs = [];
|
|
||||||
|
|
||||||
logTypes.forEach((type) => {
|
|
||||||
console[type] = function() {
|
|
||||||
const dataLogged = {
|
|
||||||
type,
|
|
||||||
dateTimeUtc: new Date().toUTCString(),
|
|
||||||
timestamp: Date.now(),
|
|
||||||
data: Array.from(arguments)
|
|
||||||
};
|
|
||||||
|
|
||||||
if (console.logs.length >= MAX_LOGS_STORED) {
|
|
||||||
console.logs.shift();
|
|
||||||
}
|
|
||||||
|
|
||||||
console.logs.push(dataLogged);
|
|
||||||
console[`${ type }Log`].apply(console, arguments);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Loading…
Reference in New Issue