Commit ee603e34 authored by Andres Käver's avatar Andres Käver
Browse files

loggind

parent e08a6321
Pipeline #780 passed with stages
in 1 minute and 12 seconds
{
"debug": true,
"testing": true
}
\ No newline at end of file
"testing": true,
"logLevel": "debug",
"backendUrl" : "http://localhost:5000/api/"
}
{
"debug": false,
"testing": false
}
\ No newline at end of file
"testing": false,
"logLevel": "debug",
"backendUrl" : "https://sportmap.akaver.com/api/"
}
import {Aurelia} from 'aurelia-framework';
import {Aurelia, LogManager} from 'aurelia-framework';
import * as environment from '../config/environment.json';
import {PLATFORM} from 'aurelia-pal';
import { ConsoleAppender } from 'aurelia-logging-console';
import 'jquery';
import 'popper.js';
......@@ -8,6 +9,35 @@ import 'bootstrap';
import 'bootstrap/dist/css/bootstrap.min.css';
import 'font-awesome/css/font-awesome.min.css';
import '../static/site.css';
import { ILogLevel } from 'types/ILogLevel';
import { queryStringValue, validateLogLevel } from 'utils/utils-general';
let logLevel = environment.logLevel;
const queryLogLevel = queryStringValue('loglevel');
if (queryLogLevel) {
logLevel = validateLogLevel(queryLogLevel);
}
LogManager.addAppender(new ConsoleAppender());
switch (logLevel) {
case ILogLevel.debug:
LogManager.setLevel(LogManager.logLevel.debug);
break;
case ILogLevel.info:
LogManager.setLevel(LogManager.logLevel.info);
break;
case ILogLevel.warn:
LogManager.setLevel(LogManager.logLevel.warn);
break;
case ILogLevel.error:
LogManager.setLevel(LogManager.logLevel.error);
break;
case ILogLevel.none:
default:
LogManager.setLevel(LogManager.logLevel.none);
break;
}
export function configure(aurelia: Aurelia): void {
aurelia.use
......
export enum ILogLevel {
debug = 'debug',
info = 'info',
warn = 'warn',
error = 'error',
none = 'none'
}
import { ILogLevel } from "types/ILogLevel";
export function queryStringValue(variableName: string): string | undefined {
return location.search
.substring(1)
.split("&")
.map((p) => p.split("="))
.filter((p) => p[0] == variableName)
.map((p) => decodeURIComponent(p[1]))
.pop();
}
export function uuidv4(): string {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
const r = Math.random() * 16 | 0;
const v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
export function validateLogLevel(logLevel: string | undefined): string {
switch (logLevel) {
case ILogLevel.debug:
return ILogLevel.debug;
case ILogLevel.info:
return ILogLevel.info;
case ILogLevel.warn:
return ILogLevel.warn;
case ILogLevel.error:
return ILogLevel.error;
case ILogLevel.none:
default:
return ILogLevel.none;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment