Winston Log File and Worker thread behavior #2899
Unanswered
capttrousers
asked this question in
Q&A
Replies: 1 comment 1 reply
-
I think this might just be that AVA runs my simple tests so fast, that the log file is never written to before the process/worker thread is torn down. If I add an await for the logger's "finish" event, it seems like my log files are written to as expected.
I still get an error in the after hook: I wonder if there's a way to make ava wait for the log to finish writing everything. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a custom Winston app logger setup that I use to write debug logs to a file (file transport), and with the default worker thread AVA behavior, the logs weren't being sent to the log file, but they were being sent to the console transport.
I thought I was able to fix the issue by upgrading to v4 and setting
"workerThreads": false
in my package.json ava config but Im still getting weird logging behavior, specifically to the file transport only.Here's a simple example of my logger:
And then in the app modules (or even the test spec files themselves)
I can get the first
something
logged, but the second log statementsomething else
isnt logged to the file transport, but it is logged to the console transport.If I add an arbitrary log statement to the test case itself, then the logging in the app just isnt sent to the file. If I remove the logging from the test case, the first log statement in the app works but none of the rest do.
I've tested that this does work when normally running the app, so it seems to be something with the AVA test runner, maybe reporters, and maybe worker threads? Or maybe something with how module export/import works in JS that I don't understand?
Or maybe the test runner is exiting so quickly that the logs are getting written?
How can I avoid this, if thats the case?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions