|
@@ -474,11 +474,9 @@
|
|
|
}
|
|
|
|
|
|
// Logs
|
|
|
- public static MessageLogLevel = 0;
|
|
|
- public static WarningLogLevel = 1;
|
|
|
- public static ErrorLogLevel = 2;
|
|
|
- public static NoneLogLevel = 3;
|
|
|
- public static CurrentLogLevel = Tools.MessageLogLevel;
|
|
|
+ public static MessageLogLevel = 1;
|
|
|
+ public static WarningLogLevel = 2;
|
|
|
+ public static ErrorLogLevel = 4;
|
|
|
|
|
|
private static _FormatMessage(message: string): string {
|
|
|
var padStr = i => (i < 10) ? "0" + i : "" + i;
|
|
@@ -487,25 +485,54 @@
|
|
|
return "BJS - [" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
|
|
|
}
|
|
|
|
|
|
- public static Log(message: string): void {
|
|
|
- if (Tools.CurrentLogLevel > Tools.MessageLogLevel) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ public static Log: (message: string) => void = Tools._LogEnabled;
|
|
|
+
|
|
|
+ private static _LogDisabled(message: string): void {
|
|
|
+ // nothing to do
|
|
|
+ }
|
|
|
+ private static _LogEnabled(message: string): void {
|
|
|
console.log(Tools._FormatMessage(message));
|
|
|
}
|
|
|
|
|
|
- public static Warn(message: string): void {
|
|
|
- if (Tools.CurrentLogLevel > Tools.WarningLogLevel) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ public static Warn: (message: string) => void = Tools._WarnEnabled;
|
|
|
+
|
|
|
+ private static _WarnDisabled(message: string): void {
|
|
|
+ // nothing to do
|
|
|
+ }
|
|
|
+ private static _WarnEnabled(message: string): void {
|
|
|
console.warn(Tools._FormatMessage(message));
|
|
|
}
|
|
|
|
|
|
- public static Error(message: string): void {
|
|
|
- if (Tools.CurrentLogLevel > Tools.ErrorLogLevel) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ public static Error: (message: string) => void = Tools._ErrorEnabled;
|
|
|
+
|
|
|
+ private static _ErrorDisabled(message: string): void {
|
|
|
+ // nothing to do
|
|
|
+ }
|
|
|
+ private static _ErrorEnabled(message: string): void {
|
|
|
console.error(Tools._FormatMessage(message));
|
|
|
}
|
|
|
+
|
|
|
+ public static SetLogLevels(level: number) {
|
|
|
+ if (level & Tools.MessageLogLevel) {
|
|
|
+ Tools.Log = Tools._LogEnabled;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Tools.Log = Tools._LogDisabled;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (level & Tools.WarningLogLevel) {
|
|
|
+ Tools.Warn = Tools._WarnEnabled;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Tools.Warn = Tools._WarnDisabled;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (level & Tools.ErrorLogLevel) {
|
|
|
+ Tools.Error = Tools._ErrorEnabled;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Tools.Error = Tools._ErrorDisabled;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|