Add a flag we can use to skip string template calcs in release

This commit is contained in:
Panayot Cankov
2016-05-17 15:36:33 +03:00
parent 114f8b47ae
commit eda260323e
42 changed files with 705 additions and 238 deletions

7
trace/trace.d.ts vendored
View File

@ -11,6 +11,13 @@ declare module "trace" {
* Disables the trace module.
*/
export function disable(): void;
/**
* A field that indicates if the tracer is enabled and there is a point in writing messages.
* Check this to avoid writing complex string templates.
* Send error messages should even if tracing is disabled.
*/
export var enabled: boolean;
/**
* Adds a TraceWriter instance to the trace module.

View File

@ -1,17 +1,17 @@
import definition = require("trace");
import * as types from "utils/types";
var _enabled = false;
export var enabled = false;
var _categories = {};
var _writers: Array<definition.TraceWriter> = [];
var _eventListeners: Array<definition.EventListener> = [];
export function enable() {
_enabled = true;
enabled = true;
}
export function disable() {
_enabled = false;
enabled = false;
}
export function isCategorySet(category: string): boolean {
@ -56,7 +56,7 @@ export function write(message: any, category: string, type?: number) {
}
}
if (!_enabled) {
if (!enabled) {
return;
}
@ -71,7 +71,7 @@ export function write(message: any, category: string, type?: number) {
}
export function notifyEvent(object: Object, name: string, data?: any) {
if (!_enabled) {
if (!enabled) {
return;
}