]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/java/rocksjni/loggerjnicallback.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / java / rocksjni / loggerjnicallback.h
CommitLineData
7c673cae 1// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
11fdf7f2
TL
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).
7c673cae
FG
5//
6// This file implements the callback "bridge" between Java and C++ for
f67539c2 7// ROCKSDB_NAMESPACE::Logger
7c673cae
FG
8
9#ifndef JAVA_ROCKSJNI_LOGGERJNICALLBACK_H_
10#define JAVA_ROCKSJNI_LOGGERJNICALLBACK_H_
11
12#include <jni.h>
1e59de90 13
7c673cae
FG
14#include <memory>
15#include <string>
1e59de90 16
7c673cae
FG
17#include "port/port.h"
18#include "rocksdb/env.h"
1e59de90 19#include "rocksjni/jnicallback.h"
7c673cae 20
f67539c2 21namespace ROCKSDB_NAMESPACE {
7c673cae 22
f67539c2
TL
23class LoggerJniCallback : public JniCallback, public Logger {
24 public:
25 LoggerJniCallback(JNIEnv* env, jobject jLogger);
26 ~LoggerJniCallback();
7c673cae 27
f67539c2 28 using Logger::GetInfoLogLevel;
1e59de90 29 using Logger::SetInfoLogLevel;
f67539c2
TL
30 // Write an entry to the log file with the specified format.
31 virtual void Logv(const char* format, va_list ap);
32 // Write an entry to the log file with the specified log level
33 // and format. Any log with level under the internal log level
34 // of *this (see @SetInfoLogLevel and @GetInfoLogLevel) will not be
35 // printed.
36 virtual void Logv(const InfoLogLevel log_level, const char* format,
37 va_list ap);
7c673cae 38
f67539c2
TL
39 private:
40 jmethodID m_jLogMethodId;
41 jobject m_jdebug_level;
42 jobject m_jinfo_level;
43 jobject m_jwarn_level;
44 jobject m_jerror_level;
45 jobject m_jfatal_level;
46 jobject m_jheader_level;
47 std::unique_ptr<char[]> format_str(const char* format, va_list ap) const;
1e59de90
TL
48};
49} // namespace ROCKSDB_NAMESPACE
7c673cae
FG
50
51#endif // JAVA_ROCKSJNI_LOGGERJNICALLBACK_H_