]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/port/win/win_logger.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / port / win / win_logger.h
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
5 //
6 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
7 // Use of this source code is governed by a BSD-style license that can be
8 // found in the LICENSE file. See the AUTHORS file for names of contributors.
9 //
10 // Logger implementation that can be shared by all environments
11 // where enough posix functionality is available.
12
13 #pragma once
14
15 #include <stdint.h>
16 #include <windows.h>
17
18 #include <atomic>
19 #include <memory>
20
21 #include "rocksdb/env.h"
22
23 namespace ROCKSDB_NAMESPACE {
24 class SystemClock;
25
26 namespace port {
27 class WinLogger : public ROCKSDB_NAMESPACE::Logger {
28 public:
29 WinLogger(uint64_t (*gettid)(), SystemClock* clock, HANDLE file,
30 const InfoLogLevel log_level = InfoLogLevel::ERROR_LEVEL);
31
32 virtual ~WinLogger();
33
34 WinLogger(const WinLogger&) = delete;
35
36 WinLogger& operator=(const WinLogger&) = delete;
37
38 void Flush() override;
39
40 using ROCKSDB_NAMESPACE::Logger::Logv;
41 void Logv(const char* format, va_list ap) override;
42
43 size_t GetLogFileSize() const override;
44
45 void DebugWriter(const char* str, int len);
46
47 protected:
48 Status CloseImpl() override;
49
50 private:
51 HANDLE file_;
52 uint64_t (*gettid_)(); // Return the thread id for the current thread
53 std::atomic_size_t log_size_;
54 std::atomic_uint_fast64_t last_flush_micros_;
55 SystemClock* clock_;
56 bool flush_pending_;
57
58 Status CloseInternal();
59
60 const static uint64_t flush_every_seconds_ = 5;
61 };
62 } // namespace port
63
64 } // namespace ROCKSDB_NAMESPACE