2016-02-09 23:12:00 +00:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-15 23:03:42 +00: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-01 23:13:49 +00: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 22:41:11 +00:00
|
|
|
#include <stdint.h>
|
2017-05-05 23:09:24 +00:00
|
|
|
#include <windows.h>
|
2015-11-16 22:41:11 +00:00
|
|
|
|
2015-07-01 23:13:49 +00:00
|
|
|
namespace rocksdb {
|
|
|
|
|
|
|
|
class Env;
|
|
|
|
|
2016-05-19 23:40:54 +00:00
|
|
|
namespace port {
|
|
|
|
|
2015-07-01 23:13:49 +00:00
|
|
|
class WinLogger : public rocksdb::Logger {
|
2015-07-13 19:11:05 +00:00
|
|
|
public:
|
2015-08-27 01:51:18 +00:00
|
|
|
WinLogger(uint64_t (*gettid)(), Env* env, HANDLE file,
|
2015-07-07 23:58:20 +00:00
|
|
|
const InfoLogLevel log_level = InfoLogLevel::ERROR_LEVEL);
|
2015-07-01 23:13:49 +00:00
|
|
|
|
2015-07-07 23:58:20 +00:00
|
|
|
virtual ~WinLogger();
|
2015-07-01 23:13:49 +00:00
|
|
|
|
2015-07-07 23:58:20 +00:00
|
|
|
WinLogger(const WinLogger&) = delete;
|
|
|
|
|
|
|
|
WinLogger& operator=(const WinLogger&) = delete;
|
2015-07-01 23:13:49 +00:00
|
|
|
|
2015-07-07 23:58:20 +00:00
|
|
|
void close();
|
2015-07-01 23:13:49 +00:00
|
|
|
|
2015-07-07 23:58:20 +00:00
|
|
|
void Flush() override;
|
2015-07-01 23:13:49 +00:00
|
|
|
|
2017-03-30 23:47:19 +00:00
|
|
|
using rocksdb::Logger::Logv;
|
2015-07-07 23:58:20 +00:00
|
|
|
void Logv(const char* format, va_list ap) override;
|
2015-07-01 23:13:49 +00:00
|
|
|
|
2015-07-07 23:58:20 +00:00
|
|
|
size_t GetLogFileSize() const override;
|
|
|
|
|
|
|
|
void DebugWriter(const char* str, int len);
|
|
|
|
|
2015-07-13 19:11:05 +00:00
|
|
|
private:
|
2015-08-27 01:51:18 +00:00
|
|
|
HANDLE file_;
|
2015-07-13 19:11:05 +00:00
|
|
|
uint64_t (*gettid_)(); // Return the thread id for the current thread
|
|
|
|
std::atomic_size_t log_size_;
|
2015-07-07 23:58:20 +00:00
|
|
|
std::atomic_uint_fast64_t last_flush_micros_;
|
2015-07-13 19:11:05 +00:00
|
|
|
Env* env_;
|
|
|
|
bool flush_pending_;
|
2015-07-01 23:13:49 +00:00
|
|
|
|
2015-07-07 23:58:20 +00:00
|
|
|
const static uint64_t flush_every_seconds_ = 5;
|
2015-07-01 23:13:49 +00:00
|
|
|
};
|
|
|
|
|
2016-05-19 23:40:54 +00:00
|
|
|
}
|
|
|
|
|
2015-07-01 23:13:49 +00:00
|
|
|
} // namespace rocksdb
|