Skip to content

Commit df21082

Browse files
Merge branch 'feature/keycloak-middleware-clean' into enhancement/openremote-client-service-register
2 parents a793b27 + 4a18dfe commit df21082

File tree

2 files changed

+9
-32
lines changed

2 files changed

+9
-32
lines changed

frontend/src/common/util.ts

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,20 @@
2424
export function getRootPath() {
2525
const scriptElement = document.querySelector('script[src*="bundle"]');
2626

27-
if (scriptElement && scriptElement.getAttribute('src')) {
27+
if (scriptElement?.getAttribute('src')) {
2828
const scriptPath = new URL(scriptElement.getAttribute('src')!, window.location.href).pathname;
2929
// Positive lookahead to match everything up to bundle.js
30-
const match = scriptPath.match(/(.*?)(?=bundle)/);
31-
return match ? (match[1].endsWith('/') ? match[1].slice(0, -1) : match[1]) : '';
30+
const regex = /(.*?)(?=bundle)/;
31+
const match = regex.exec(scriptPath);
32+
let rootPath = '';
33+
if (match) {
34+
rootPath = match[1].endsWith('/') ? match[1].slice(0, -1) : match[1];
35+
}
36+
return rootPath;
3237
}
3338
return '';
3439
}
3540

36-
/**
37-
* Setup console logging to add a prefix to all console logs
38-
* Enabling proper distinction between logs from the service and other sources
39-
*/
40-
export function setupConsoleLogging() {
41-
const originalConsoleLog = console.log;
42-
console.log = (...args) => {
43-
originalConsoleLog('[ml-forecast]', ...args);
44-
};
45-
46-
const originalConsoleInfo = console.info;
47-
console.info = (...args) => {
48-
originalConsoleInfo('[ml-forecast]', ...args);
49-
};
50-
51-
const originalConsoleWarn = console.warn;
52-
console.warn = (...args) => {
53-
originalConsoleWarn('[ml-forecast]', ...args);
54-
};
55-
56-
const originalConsoleError = console.error;
57-
console.error = (...args) => {
58-
originalConsoleError('[ml-forecast]', ...args);
59-
};
60-
}
61-
6241
/**
6342
* Get the realm search param from the url (?realm=)
6443
* @returns The realm search param

frontend/src/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import { setupORIcons } from './common/theme';
1919
import { setupRouter } from './router';
2020
import { IS_EMBEDDED, ML_OR_KEYCLOAK_URL, ML_OR_URL } from './common/constants';
21-
import { getRealmSearchParam, setupConsoleLogging } from './common/util';
21+
import { getRealmSearchParam } from './common/util';
2222
import { manager } from '@openremote/core';
2323
import { Auth, EventProviderType, ManagerConfig } from '@openremote/model';
2424

@@ -32,8 +32,6 @@ import './components/loading-spinner';
3232
import './components/breadcrumb-nav';
3333
import './components/alert-message';
3434

35-
// Override default log statements with service prefix
36-
setupConsoleLogging();
3735

3836
const DEFAULT_MANAGER_CONFIG: ManagerConfig = {
3937
managerUrl: ML_OR_URL || '/',

0 commit comments

Comments
 (0)