Server: Tidy up logger initialisation

  • Konuyu Başlatan Konuyu Başlatan twostars
  • Başlangıç tarihi Başlangıç tarihi
  • Öne çıkan
T

twostars

Server: Tidy up logger initialisation

Previously this would be manually initialised within App::OnStart(), after config is loaded so that it can fetch the associated logger config.
This creates a problem with ftxui/renderer setup; it really should be rendering throughout startup, so we don't have to be awkwardly swapping
from 'raw' console back to the ftxui rendered container.

To rectify this, we abstract config loading to handle it under AppThread.
It loads the config file (which no longer bothers to report its warning since that's useless at this stage now; the logger isn't setup yet),
then sets up the logger.
Once the logger's setup, it can report the warning that was being unintentionally ignored, and continue to spin up the renderer thread.

Once the renderer thread's spun up, THEN we can start the application-specific startup logic. This can continue to be done in the main thread
because the renderer has its own thread, but we just need to ensure it's run after the renderer's started.

From here, we can directly invoke the application-specific config to be loaded (via LoadConfig()) before OnStart() is called, which is
for the most part pretty much what it was doing before (AI was really the only exception, but it was only a few members being initialized before it).

Logic then behaves as before -- but for the most part, it should always have been rendered under the ftxui sink, rather than console first.
I would otherwise remove the somewhat hacky swap logic, but there's still technically a case for the brief window between the renderer thread spinning up
and OnStart being called (we don't wait to ensure it's actually running, we just dispatch it and continue).

This just means the transition continues to be pretty seamless so no big deal there.

The other thing is, since the server hasn't yet started up, I don't bother rendering (or processing) command input.

All in all, this means that logging is fairly consistent the entire way through even though we continue to carry the slight console/ftxui sink hackery forward.

Github Commit Görüntüle...
See Commints...

..
 

Similar threads

T
Cevaplar
0
Görüntüleme
18
twostars
T
T
Cevaplar
0
Görüntüleme
3
T
K
Cevaplar
0
Görüntüleme
38
kenner2
K
T
Cevaplar
0
Görüntüleme
31
twostars
T
T
Cevaplar
0
Görüntüleme
11
twostars
T
Geri
Üst