Skip to content

Commit ac7fe95

Browse files
committed
Refactored WebSocketImpl to fix thread-safety
1 parent 4ea0876 commit ac7fe95

3 files changed

Lines changed: 521 additions & 468 deletions

File tree

LiteCore/Logging/Logging.hh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ namespace litecore {
198198

199199
private:
200200
friend class LogDomain;
201+
friend class LoggingProxy;
201202

202203
mutable LogObjectRef _objectRef{};
203204
};
@@ -216,4 +217,26 @@ namespace litecore {
216217
# define logDebug(FMT, ...)
217218
#endif
218219

220+
/** A class that delegates logging methods to an instance of Logging. */
221+
class LoggingProxy {
222+
public:
223+
explicit LoggingProxy(Logging* logging) : _logging(logging) {}
224+
225+
protected:
226+
bool willLog(LogLevel level = LogLevel::Info) const { return _logging->willLog(level); }
227+
228+
void warn(const char* format, ...) const __printflike(2, 3) { LOGBODY(Warning) }
229+
230+
void logError(const char* format, ...) const __printflike(2, 3) { LOGBODY(Error) }
231+
232+
void _log(LogLevel level, const char* format, ...) const __printflike(3, 4) { LOGBODY_(level) }
233+
234+
void _logv(LogLevel level, const char* format, va_list args) const __printflike(3, 0) {
235+
_logging->_logv(level, format, args);
236+
}
237+
238+
private:
239+
Logging* const _logging;
240+
};
241+
219242
} // namespace litecore

0 commit comments

Comments
 (0)