2016-02-10 00:12:00 +01:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-16 01:03:42 +02:00
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
2015-07-02 01:13:49 +02:00
|
|
|
//
|
|
|
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
//
|
|
|
|
// Logger implementation that can be shared by all environments
|
|
|
|
// where enough posix functionality is available.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-01-06 19:48:24 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <windows.h>
|
|
|
|
|
2015-07-02 01:13:49 +02:00
|
|
|
#include <atomic>
|
2021-01-06 19:48:24 +01:00
|
|
|
#include <memory>
|
2015-07-02 01:13:49 +02:00
|
|
|
|
|
|
|
#include "rocksdb/env.h"
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
2021-01-26 07:07:26 +01:00
|
|
|
class SystemClock;
|
2015-07-02 01:13:49 +02:00
|
|
|
|
2016-05-20 01:40:54 +02:00
|
|
|
namespace port {
|
2020-02-20 21:07:53 +01:00
|
|
|
class WinLogger : public ROCKSDB_NAMESPACE::Logger {
|
2015-07-13 21:11:05 +02:00
|
|
|
public:
|
2021-03-15 12:32:24 +01:00
|
|
|
WinLogger(uint64_t (*gettid)(), SystemClock* clock, HANDLE file,
|
2015-07-08 01:58:20 +02:00
|
|
|
const InfoLogLevel log_level = InfoLogLevel::ERROR_LEVEL);
|
2015-07-02 01:13:49 +02:00
|
|
|
|
2015-07-08 01:58:20 +02:00
|
|
|
virtual ~WinLogger();
|
2015-07-02 01:13:49 +02:00
|
|
|
|
2015-07-08 01:58:20 +02:00
|
|
|
WinLogger(const WinLogger&) = delete;
|
|
|
|
|
|
|
|
WinLogger& operator=(const WinLogger&) = delete;
|
2015-07-02 01:13:49 +02:00
|
|
|
|
2015-07-08 01:58:20 +02:00
|
|
|
void Flush() override;
|
2015-07-02 01:13:49 +02:00
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
using ROCKSDB_NAMESPACE::Logger::Logv;
|
2015-07-08 01:58:20 +02:00
|
|
|
void Logv(const char* format, va_list ap) override;
|
2015-07-02 01:13:49 +02:00
|
|
|
|
2015-07-08 01:58:20 +02:00
|
|
|
size_t GetLogFileSize() const override;
|
|
|
|
|
|
|
|
void DebugWriter(const char* str, int len);
|
|
|
|
|
2018-03-06 20:47:42 +01:00
|
|
|
protected:
|
|
|
|
|
|
|
|
Status CloseImpl() override;
|
|
|
|
|
2015-07-13 21:11:05 +02:00
|
|
|
private:
|
2015-08-27 03:51:18 +02:00
|
|
|
HANDLE file_;
|
2015-07-13 21:11:05 +02:00
|
|
|
uint64_t (*gettid_)(); // Return the thread id for the current thread
|
|
|
|
std::atomic_size_t log_size_;
|
2015-07-08 01:58:20 +02:00
|
|
|
std::atomic_uint_fast64_t last_flush_micros_;
|
2021-03-15 12:32:24 +01:00
|
|
|
SystemClock* clock_;
|
2015-07-13 21:11:05 +02:00
|
|
|
bool flush_pending_;
|
2015-07-02 01:13:49 +02:00
|
|
|
|
2018-03-06 20:47:42 +01:00
|
|
|
Status CloseInternal();
|
|
|
|
|
2015-07-08 01:58:20 +02:00
|
|
|
const static uint64_t flush_every_seconds_ = 5;
|
2015-07-02 01:13:49 +02:00
|
|
|
};
|
2016-05-20 01:40:54 +02:00
|
|
|
}
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|