@qusav1n said in Лайфхаки BAS:
Не понимаю, как реализовать? Можешь подробнее пояснить решение
getActionId = function() {
return "[" + ScriptWorker.GetCurrentAction() + "]";
}
getTime = function(){
var checkTime = function(i) {
return (i < 10) ? ("0" + i) : i;
};
var d = new Date();
var hh = checkTime(d.getHours());
var mm = checkTime(d.getMinutes());
var ss = checkTime(d.getSeconds());
return '[' + hh + ':' + mm + ':' + ss + ']';
};
wrapLog = function(msg) {
return getActionId() + ' ' + getTime() + ' [Thread #' + thread_number() + '] ' + msg;
}
writeLogToFile = function(msg) {
var wrappedMsg = wrapLog(msg);
native("filesystem", "writefile", JSON.stringify({path: JSON.parse(P("basglobal", "LOGS_FILE_TXT") || '""'), value: (wrappedMsg).toString() + "\r\n", base64:false, append:true}));
}
original_log_fn = log;
log = function(msg) {
original_log_fn(msg);
writeLogToFile(msg);
}