xfangfang / borealis

Hardware accelerated, Nintendo Switch inspired UI library for PC, Android, iOS, PSV, PS4 and Nintendo Switch
Apache License 2.0
31 stars 21 forks source link

Thread safe logging #75

Closed ThisALV closed 2 months ago

ThisALV commented 8 months ago

This PR adds Logger::setThreadSafeLogging(bool) and if true is passed the logging methods will lock a mutex before printing to logOutput and firing logEvent

xfangfang commented 8 months ago

Look good to me. cc @dragonflylee @XITRIX

XITRIX commented 8 months ago

Good, not sure why we even need not thread safe logging, btw

Is there any reason to make it "false" by default, or not use mutex without any checks?

ThisALV commented 8 months ago

Good, not sure why we even need not thread safe logging, btw

Is there any reason to make it "false" by default, or not use mutex without any checks?

I thought most application are single threaded or didn't log from async task thread so it would avoid the overhead of locking the mutex in those cases, but that overhead might be kinda small so I'm not really sure.

I let you decide what default value we should use for that property

ThisALV commented 2 months ago

I enabled thread safe logging by default. Could the PR be merge ?

XITRIX commented 2 months ago

Looks good to me