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

84 lines
1.7 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-05-02 00:23:40 +00:00
import {log} from "./beautylog.log.helpers";
export {log} from "./beautylog.log.helpers";
2016-02-23 13:34:40 +00:00
/**
* logs an info to console
* @param logText
* @returns {boolean}
*/
2016-06-16 00:17:28 +00:00
export let info = (logText) => {
2016-02-23 13:34:40 +00:00
return log(logText, 'info');
};
/**
* logs an 'OK!' message to console
* @param logText
* @returns {boolean}
*/
2016-06-16 00:17:28 +00:00
export let ok = (logText) => {
2016-02-23 13:34:40 +00:00
return log(logText, 'ok');
};
/**
* 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-02-23 13:34:40 +00:00
return log(logText, 'success');
};
/**
* 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-02-23 13:34:40 +00:00
return log(logText, 'warn');
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-05-02 00:23:40 +00:00
return log(logText, 'error');
};
/**
* logs an directory to console
* @param logText
* @returns {boolean}
*/
2016-06-16 00:17:28 +00:00
export let dir = (logText) => {
2016-05-02 00:23:40 +00:00
return log(logText, 'dir');
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;