2020-08-14 18:58:22 +02:00
|
|
|
#ifndef TGCALLS_LOG_SINK_IMPL_H
|
|
|
|
#define TGCALLS_LOG_SINK_IMPL_H
|
|
|
|
|
|
|
|
#include "rtc_base/logging.h"
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
namespace tgcalls {
|
|
|
|
|
2020-12-23 08:48:30 +01:00
|
|
|
struct FilePath;
|
2020-08-14 18:58:22 +02:00
|
|
|
|
|
|
|
class LogSinkImpl final : public rtc::LogSink {
|
|
|
|
public:
|
2020-12-23 08:48:30 +01:00
|
|
|
LogSinkImpl(const FilePath &logPath);
|
2020-08-14 18:58:22 +02:00
|
|
|
|
|
|
|
void OnLogMessage(const std::string &msg, rtc::LoggingSeverity severity, const char *tag) override;
|
|
|
|
void OnLogMessage(const std::string &message, rtc::LoggingSeverity severity) override;
|
|
|
|
void OnLogMessage(const std::string &message) override;
|
|
|
|
|
|
|
|
std::string result() const {
|
|
|
|
return _data.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::ofstream _file;
|
|
|
|
std::ostringstream _data;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace tgcalls
|
|
|
|
|
|
|
|
#endif
|