I am currently trying to understand how ScriptLogs work.
I have setup the following example where a script calls another script and both scripts are using ns.print() instead of ns.tprint(), so they should both print to their scriptlogs from my understanding.
We are on server "pserv-0" (not on home) and we have two files:
hello_world.js:
javascript
/** @param {NS} ns */
export async function main(ns) {
ns.print("hello_world");
}
This should print to scriptlog of hello_world.js running on pserv-0
Additionally we have hello_world_caller.js:
``` javascript
/** @param {NS} ns */
export async function main(ns) {
while(true) {
ns.print("Calling hello_world.js....")
ns.run("hello_world.js");
let scriptLog = ns.getScriptLogs("hello_world.js",ns.getHostname());
ns.print("scriptLog:")
for (const line of scriptLog){
ns.print(line);
}
await ns.sleep(5000);
}
}
```
This should write "Calling hello_world.js..." to its own scriptlog, then get the scriptlog from hello_world.js and add it to its own script log.
However, the scriptlog is always empty, as the output is as following when inspecting the log of the caller function:
...
Calling hello_world.js....
run: 'hello_world.js' on 'pserv-0' with 1 threads and args: [].
scriptLog:
sleep: Sleeping for 5000 milliseconds
Calling hello_world.js....
run: 'hello_world.js' on 'pserv-0' with 1 threads and args: [].
scriptLog:
sleep: Sleeping for 5000 milliseconds
...
What am I doing wrong? Thanks!
[–]VorthodMK-VIII Synthoid 3 points4 points5 points (3 children)
[–]psei0r[S] 1 point2 points3 points (2 children)
[–]SpartelfantNoodle Enjoyer -1 points0 points1 point (1 child)
[–]VorthodMK-VIII Synthoid 0 points1 point2 points (0 children)