smartlog-destination-local/ts/beautylog.log.ts

88 lines
1.8 KiB
TypeScript
Raw Normal View History

2016-05-23 07:10:30 +00:00
import "typings-global";
2016-02-23 13:34:40 +00:00
2016-07-23 23:17:38 +00:00
import {internalLog} from "./beautylog.log.helpers";
2016-02-23 13:34:40 +00:00
/**
* logs an info to console
* @param logText
* @returns {boolean}
*/
2016-07-23 23:17:38 +00:00
export let log = (logText) => {
return internalLog("log",logText)
}
2016-06-16 00:17:28 +00:00
export let info = (logText) => {
2016-07-23 23:17:38 +00:00
return internalLog('info',logText);
2016-02-23 13:34:40 +00:00
};
/**
* logs an 'OK!' message to console
* @param logText
* @returns {boolean}
*/
2016-06-16 00:17:28 +00:00
export let ok = (logText) => {
2016-07-23 23:17:38 +00:00
return internalLog("ok",logText);
2016-02-23 13:34:40 +00:00
};
/**
* logs a success to console
* @param logText string to log as error
* @returns {boolean}
*/
2016-06-16 00:17:28 +00:00
export let success = (logText) => {
2016-07-23 23:17:38 +00:00
return internalLog("success",logText);
2016-02-23 13:34:40 +00:00
};
/**
* logs a 'warn:' message to console
* @param logText string to log as error
* @returns {boolean}
*/
2016-06-16 00:17:28 +00:00
export let warn = (logText) => {
2016-07-23 23:17:38 +00:00
return internalLog("warn",logText);
2016-05-02 00:23:40 +00:00
};
/**
* logs an error to console
* @param logText
* @returns {boolean}
*/
2016-06-16 00:17:28 +00:00
export let error = (logText) => {
2016-07-23 23:17:38 +00:00
return internalLog("error",logText);
2016-05-02 00:23:40 +00:00
};
/**
* logs an directory to console
* @param logText
* @returns {boolean}
*/
2016-06-16 00:17:28 +00:00
export let dir = (logText) => {
2016-07-23 23:17:38 +00:00
return internalLog("dir",logText);
2016-06-16 00:17:28 +00:00
};
2016-06-16 21:57:49 +00:00
/**
* creates a new empty line
* @param linesArg
* @returns void
*/
2016-06-16 00:17:28 +00:00
export let newLine = (linesArg:number = 1) => {
for(let i = 0; i < linesArg;i++){
console.log("\n");
}
2016-06-16 21:57:49 +00:00
}
/**
* logs a reduced log that only logs changes of consequential log messages
*/
export let logReduced = (logTextArg:string,repeatEveryTimesArg:number = 0) => {
if(logTextArg == previousMessage && (repeatEveryTimesArg == 0 || sameMessageCounter != repeatEveryTimesArg)){
sameMessageCounter++;
} else {
sameMessageCounter = 0;
previousMessage = logTextArg;
log(logTextArg);
}
};
let previousMessage:string = "";
let sameMessageCounter:number = 0;