cleanup, download lit, log function

This commit is contained in:
2022-09-12 01:33:24 +02:00
parent 3529597fb0
commit 2963efd97b
13 changed files with 123 additions and 83 deletions
+20 -4
View File
@@ -32,10 +32,6 @@
"",
"export async function main(ns) {",
" // ns.disableLog('ALL');",
"",
" async function writeLog(obj) {",
" await ns.tryWritePort($1, obj + '\\n');",
" }",
" ",
" $2",
"}"
@@ -60,6 +56,26 @@
],
"description": "NS terminal print"
},
"writelog": {
"scope": "",
"prefix": "writelog",
"body": [
"async function writeLog(type, obj) {",
" let timeNow = new Date();",
" let year = timeNow.getFullYear().toString().substring(2);",
" let month = (timeNow.getMonth() < 9 ? '0' : '') + (timeNow.getMonth() + 1);",
" let day = (timeNow.getDate() < 10 ? '0' : '') + timeNow.getDate();",
" let hour = (timeNow.getHours() < 10 ? '0' : '') + timeNow.getHours();",
" let minute = (timeNow.getMinutes() < 10 ? '0' : '') + timeNow.getMinutes();",
" let second = (timeNow.getSeconds() < 10 ? '0' : '') + timeNow.getSeconds();",
" let timestamp = `\\${year}\\${month}\\${day}_\\${hour}\\${minute}\\${second}`;",
" await ns.tryWritePort($1, `t\\${timestamp}_\\${type} = \\${obj};\\n`);",
" ",
" if (['ERROR', 'TERMINAL'].indexOf(type) != -1) ns.tprint(`\\${timestamp} \\${type} = \\${obj}`);",
"}"
],
"description": "writelog function definition"
},
"log": {
"scope": "",
"prefix": "log",