tdlight/tdutils/td/utils/FileLog.h
Arseny Smirnov f63ce74fef tdutils: import changes from other project
GitOrigin-RevId: 0cfbe2418933cffdce4f0d1b8461c247a814d868
2019-08-12 14:45:57 +03:00

46 lines
1.0 KiB
C++

//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include "td/utils/common.h"
#include "td/utils/logging.h"
#include "td/utils/port/FileFd.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
namespace td {
class FileLog : public LogInterface {
static constexpr int64 DEFAULT_ROTATE_THRESHOLD = 10 * (1 << 20);
public:
Status init(string path, int64 rotate_threshold = DEFAULT_ROTATE_THRESHOLD, bool redirect_stderr = true);
Slice get_path() const;
vector<string> get_file_paths() override;
void set_rotate_threshold(int64 rotate_threshold);
int64 get_rotate_threshold() const;
void append(CSlice cslice, int log_level) override;
void rotate() override;
private:
FileFd fd_;
string path_;
int64 size_ = 0;
int64 rotate_threshold_ = 0;
bool redirect_stderr_;
void do_rotate();
};
} // namespace td