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
|
|
|
|
|
|
|
|
#include <atomic>
|
|
|
|
|
|
|
|
#include "rocksdb/env.h"
|
|
|
|
|
2015-11-16 23:41:11 +01:00
|
|
|
#include <stdint.h>
|
2017-05-06 01:09:24 +02:00
|
|
|
#include <windows.h>
|
2015-11-16 23:41:11 +01:00
|
|
|
|
2015-07-02 01:13:49 +02:00
|
|
|
namespace rocksdb {
|
|
|
|
|
|
|
|
class Env;
|
|
|
|
|
2016-05-20 01:40:54 +02:00
|
|
|
namespace port {
|
|
|
|
|
2015-07-02 01:13:49 +02:00
|
|
|
class WinLogger : public rocksdb::Logger {
|
2015-07-13 21:11:05 +02:00
|
|
|
public:
|
2015-08-27 03:51:18 +02:00
|
|
|
WinLogger(uint64_t (*gettid)(), Env* env, 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
|
|
|
|
2017-03-31 01:47:19 +02:00
|
|
|
using rocksdb::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_;
|
2015-07-13 21:11:05 +02:00
|
|
|
Env* env_;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-07-02 01:13:49 +02:00
|
|
|
} // namespace rocksdb
|