empiricaly / empirica

Open source project to tackle the problem of long development cycles required to produce software to conduct multi-participant and real-time human experiments online.
https://empirica.ly/
Apache License 2.0
43 stars 8 forks source link

Server logging during app initialization produces output only after application hot reload. #547

Open kaglowka opened 3 months ago

kaglowka commented 3 months ago

Is there an existing issue for this?

What happened?

Logging using empirica/core/console doesn't initially print data in the console. Logs are displayed only on hot reload.

I loaded (from a file) external additional data used in my experiment and I tried to print some information on it in the console, so I see what data the current Empirica server uses.

I don't know what's the reason. As you can see below I tried to log both in the main thread as well as within a new thread. I imagine any of these two solutions would be more than fine:

Steps To Reproduce

  1. create new experiment project
  2. add in index.js or callbacks.js
    
    import { info, error} from "@empirica/core/console";
    function printSync() {
    info('output 1')
    error('output 2')
    console.info('output 3')
    console.error('output 4')
    }
    function printAsync() {
    info('output 5')
    error('output 6')
    console.info('output 7')
    console.error('output 8')
    }

printSync(); (async () => printAsync())();


**Output**

[server] output 4 [server] output 8

Empirica (build #208) server running:

  Player  http://localhost:3000                                                                     
  Admin   http://localhost:3000/admin                                                               
 On adding any change to the file and saving:

14:10:10.514 ERR callbacks: exited, retrying error="exit status 1" [server] building file list ... [server] 0 files to consider [server] 14:10:12.016 INF output 1 [server] 14:10:12.017 ERR output 2 [server] output 3 [server] output 4 [server] 14:10:12.018 INF output 5 [server] 14:10:12.018 ERR output 6 [server] output 7 [server] output 8 [server] 14:10:12.433 INF server: started server refreshed


### Empirica Version

```text
1.10

What OS are you seeing the problem on?

Linux (Ubuntu 22.04)

What browser are you seeing the problem on?

Does not apply

Relevant log output

No response

Anything else?

Code of Conduct

npaton commented 2 months ago

Startup logs are indeed muted at startup. You should be able to get back startup logs with --log.level debug. I will look into always printing logs at startup.