#ifndef LOGGER_H #define LOGGER_H #include #include #include class Logger { private: QDebug *out; QMutex mutex; QFile *file; public: Logger(QFile *file); Logger(Logger &&o); template Logger &operator <<(const T &val) { QMutexLocker locker(&this->mutex); *out << val; //TODO: QDebug may not have flushed yet file->flush(); return *this; } template Logger &operator <<(const T *val) { QMutexLocker locker(&this->mutex); *out << val; //TODO: QDebug may not have flushed yet file->flush(); return *this; } ~Logger() { delete out; } static Logger& error(); static Logger& info(); }; #endif // LOGGER_H