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-02-10 20:59:40 +00:00
|
|
|
//
|
|
|
|
// This file implements the callback "bridge" between Java and C++ for
|
2020-02-20 20:07:53 +00:00
|
|
|
// ROCKSDB_NAMESPACE::Logger.
|
2015-02-10 20:59:40 +00:00
|
|
|
|
2022-03-01 17:02:15 +00:00
|
|
|
#include "rocksjni/loggerjnicallback.h"
|
2015-02-10 20:59:40 +00:00
|
|
|
|
2017-02-28 00:26:12 +00:00
|
|
|
#include <cstdarg>
|
|
|
|
#include <cstdio>
|
2022-03-01 17:02:15 +00:00
|
|
|
|
|
|
|
#include "include/org_rocksdb_Logger.h"
|
|
|
|
#include "rocksjni/cplusplus_to_java_convert.h"
|
2018-04-13 00:55:14 +00:00
|
|
|
#include "rocksjni/portal.h"
|
2015-02-10 20:59:40 +00:00
|
|
|
|
2020-02-20 20:07:53 +00:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
2015-02-10 20:59:40 +00:00
|
|
|
|
2018-04-13 00:55:14 +00:00
|
|
|
LoggerJniCallback::LoggerJniCallback(JNIEnv* env, jobject jlogger)
|
|
|
|
: JniCallback(env, jlogger) {
|
2015-03-10 22:16:21 +00:00
|
|
|
m_jLogMethodId = LoggerJni::getLogMethodId(env);
|
2018-04-13 00:55:14 +00:00
|
|
|
if (m_jLogMethodId == nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
// exception thrown: NoSuchMethodException or OutOfMemoryError
|
|
|
|
return;
|
|
|
|
}
|
2016-07-28 23:54:06 +00:00
|
|
|
|
|
|
|
jobject jdebug_level = InfoLogLevelJni::DEBUG_LEVEL(env);
|
2018-04-13 00:55:14 +00:00
|
|
|
if (jdebug_level == nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
// exception thrown: NoSuchFieldError, ExceptionInInitializerError
|
|
|
|
// or OutOfMemoryError
|
|
|
|
return;
|
|
|
|
}
|
2016-07-28 23:54:06 +00:00
|
|
|
m_jdebug_level = env->NewGlobalRef(jdebug_level);
|
2018-04-13 00:55:14 +00:00
|
|
|
if (m_jdebug_level == nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
// exception thrown: OutOfMemoryError
|
|
|
|
return;
|
|
|
|
}
|
2016-07-28 23:54:06 +00:00
|
|
|
|
|
|
|
jobject jinfo_level = InfoLogLevelJni::INFO_LEVEL(env);
|
2018-04-13 00:55:14 +00:00
|
|
|
if (jinfo_level == nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
// exception thrown: NoSuchFieldError, ExceptionInInitializerError
|
|
|
|
// or OutOfMemoryError
|
|
|
|
return;
|
|
|
|
}
|
2016-07-28 23:54:06 +00:00
|
|
|
m_jinfo_level = env->NewGlobalRef(jinfo_level);
|
2018-04-13 00:55:14 +00:00
|
|
|
if (m_jinfo_level == nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
// exception thrown: OutOfMemoryError
|
|
|
|
return;
|
|
|
|
}
|
2016-07-28 23:54:06 +00:00
|
|
|
|
|
|
|
jobject jwarn_level = InfoLogLevelJni::WARN_LEVEL(env);
|
2018-04-13 00:55:14 +00:00
|
|
|
if (jwarn_level == nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
// exception thrown: NoSuchFieldError, ExceptionInInitializerError
|
|
|
|
// or OutOfMemoryError
|
|
|
|
return;
|
|
|
|
}
|
2016-07-28 23:54:06 +00:00
|
|
|
m_jwarn_level = env->NewGlobalRef(jwarn_level);
|
2018-04-13 00:55:14 +00:00
|
|
|
if (m_jwarn_level == nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
// exception thrown: OutOfMemoryError
|
|
|
|
return;
|
|
|
|
}
|
2016-07-28 23:54:06 +00:00
|
|
|
|
|
|
|
jobject jerror_level = InfoLogLevelJni::ERROR_LEVEL(env);
|
2018-04-13 00:55:14 +00:00
|
|
|
if (jerror_level == nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
// exception thrown: NoSuchFieldError, ExceptionInInitializerError
|
|
|
|
// or OutOfMemoryError
|
|
|
|
return;
|
|
|
|
}
|
2016-07-28 23:54:06 +00:00
|
|
|
m_jerror_level = env->NewGlobalRef(jerror_level);
|
2018-04-13 00:55:14 +00:00
|
|
|
if (m_jerror_level == nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
// exception thrown: OutOfMemoryError
|
|
|
|
return;
|
|
|
|
}
|
2016-07-28 23:54:06 +00:00
|
|
|
|
|
|
|
jobject jfatal_level = InfoLogLevelJni::FATAL_LEVEL(env);
|
2018-04-13 00:55:14 +00:00
|
|
|
if (jfatal_level == nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
// exception thrown: NoSuchFieldError, ExceptionInInitializerError
|
|
|
|
// or OutOfMemoryError
|
|
|
|
return;
|
|
|
|
}
|
2016-07-28 23:54:06 +00:00
|
|
|
m_jfatal_level = env->NewGlobalRef(jfatal_level);
|
2018-04-13 00:55:14 +00:00
|
|
|
if (m_jfatal_level == nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
// exception thrown: OutOfMemoryError
|
|
|
|
return;
|
|
|
|
}
|
2016-07-28 23:54:06 +00:00
|
|
|
|
|
|
|
jobject jheader_level = InfoLogLevelJni::HEADER_LEVEL(env);
|
2018-04-13 00:55:14 +00:00
|
|
|
if (jheader_level == nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
// exception thrown: NoSuchFieldError, ExceptionInInitializerError
|
|
|
|
// or OutOfMemoryError
|
|
|
|
return;
|
|
|
|
}
|
2016-07-28 23:54:06 +00:00
|
|
|
m_jheader_level = env->NewGlobalRef(jheader_level);
|
2018-04-13 00:55:14 +00:00
|
|
|
if (m_jheader_level == nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
// exception thrown: OutOfMemoryError
|
|
|
|
return;
|
|
|
|
}
|
2015-02-10 20:59:40 +00:00
|
|
|
}
|
|
|
|
|
2018-04-13 00:55:14 +00:00
|
|
|
void LoggerJniCallback::Logv(const char* /*format*/, va_list /*ap*/) {
|
2015-02-10 20:59:40 +00:00
|
|
|
// We implement this method because it is virtual but we don't
|
|
|
|
// use it because we need to know about the log level.
|
|
|
|
}
|
|
|
|
|
2018-04-13 00:55:14 +00:00
|
|
|
void LoggerJniCallback::Logv(const InfoLogLevel log_level, const char* format,
|
|
|
|
va_list ap) {
|
2015-02-10 20:59:40 +00:00
|
|
|
if (GetInfoLogLevel() <= log_level) {
|
2015-03-10 22:16:21 +00:00
|
|
|
// determine InfoLogLevel java enum instance
|
|
|
|
jobject jlog_level;
|
|
|
|
switch (log_level) {
|
2020-02-20 20:07:53 +00:00
|
|
|
case ROCKSDB_NAMESPACE::InfoLogLevel::DEBUG_LEVEL:
|
2016-07-28 23:54:06 +00:00
|
|
|
jlog_level = m_jdebug_level;
|
2015-03-10 22:16:21 +00:00
|
|
|
break;
|
2020-02-20 20:07:53 +00:00
|
|
|
case ROCKSDB_NAMESPACE::InfoLogLevel::INFO_LEVEL:
|
2016-07-28 23:54:06 +00:00
|
|
|
jlog_level = m_jinfo_level;
|
|
|
|
break;
|
2020-02-20 20:07:53 +00:00
|
|
|
case ROCKSDB_NAMESPACE::InfoLogLevel::WARN_LEVEL:
|
2016-07-28 23:54:06 +00:00
|
|
|
jlog_level = m_jwarn_level;
|
2015-03-10 22:16:21 +00:00
|
|
|
break;
|
2020-02-20 20:07:53 +00:00
|
|
|
case ROCKSDB_NAMESPACE::InfoLogLevel::ERROR_LEVEL:
|
2016-07-28 23:54:06 +00:00
|
|
|
jlog_level = m_jerror_level;
|
2015-03-10 22:16:21 +00:00
|
|
|
break;
|
2020-02-20 20:07:53 +00:00
|
|
|
case ROCKSDB_NAMESPACE::InfoLogLevel::FATAL_LEVEL:
|
2016-07-28 23:54:06 +00:00
|
|
|
jlog_level = m_jfatal_level;
|
|
|
|
break;
|
2020-02-20 20:07:53 +00:00
|
|
|
case ROCKSDB_NAMESPACE::InfoLogLevel::HEADER_LEVEL:
|
2016-07-28 23:54:06 +00:00
|
|
|
jlog_level = m_jheader_level;
|
2015-03-10 22:16:21 +00:00
|
|
|
break;
|
|
|
|
default:
|
2016-07-28 23:54:06 +00:00
|
|
|
jlog_level = m_jfatal_level;
|
2015-03-10 22:16:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-02-28 00:26:12 +00:00
|
|
|
assert(format != nullptr);
|
|
|
|
const std::unique_ptr<char[]> msg = format_str(format, ap);
|
2016-07-28 23:54:06 +00:00
|
|
|
|
2017-02-28 00:26:12 +00:00
|
|
|
// pass msg to java callback handler
|
|
|
|
jboolean attached_thread = JNI_FALSE;
|
2017-10-12 18:06:51 +00:00
|
|
|
JNIEnv* env = getJniEnv(&attached_thread);
|
2017-02-28 00:26:12 +00:00
|
|
|
assert(env != nullptr);
|
2015-02-10 20:59:40 +00:00
|
|
|
|
2017-02-28 00:26:12 +00:00
|
|
|
jstring jmsg = env->NewStringUTF(msg.get());
|
2018-04-13 00:55:14 +00:00
|
|
|
if (jmsg == nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
// unable to construct string
|
2018-04-13 00:55:14 +00:00
|
|
|
if (env->ExceptionCheck()) {
|
|
|
|
env->ExceptionDescribe(); // print out exception to stderr
|
2015-02-10 20:59:40 +00:00
|
|
|
}
|
2017-10-12 18:06:51 +00:00
|
|
|
releaseJniEnv(attached_thread);
|
2017-02-28 00:26:12 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-04-13 00:55:14 +00:00
|
|
|
if (env->ExceptionCheck()) {
|
2017-02-28 00:26:12 +00:00
|
|
|
// exception thrown: OutOfMemoryError
|
2018-04-13 00:55:14 +00:00
|
|
|
env->ExceptionDescribe(); // print out exception to stderr
|
2017-02-28 00:26:12 +00:00
|
|
|
env->DeleteLocalRef(jmsg);
|
2017-10-12 18:06:51 +00:00
|
|
|
releaseJniEnv(attached_thread);
|
2017-02-28 00:26:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-12 18:06:51 +00:00
|
|
|
env->CallVoidMethod(m_jcallback_obj, m_jLogMethodId, jlog_level, jmsg);
|
2018-04-13 00:55:14 +00:00
|
|
|
if (env->ExceptionCheck()) {
|
2017-02-28 00:26:12 +00:00
|
|
|
// exception thrown
|
2018-04-13 00:55:14 +00:00
|
|
|
env->ExceptionDescribe(); // print out exception to stderr
|
2017-02-28 00:26:12 +00:00
|
|
|
env->DeleteLocalRef(jmsg);
|
2017-10-12 18:06:51 +00:00
|
|
|
releaseJniEnv(attached_thread);
|
2017-02-28 00:26:12 +00:00
|
|
|
return;
|
2015-02-10 20:59:40 +00:00
|
|
|
}
|
2017-02-28 00:26:12 +00:00
|
|
|
|
|
|
|
env->DeleteLocalRef(jmsg);
|
2017-10-12 18:06:51 +00:00
|
|
|
releaseJniEnv(attached_thread);
|
2015-02-10 20:59:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-13 00:55:14 +00:00
|
|
|
std::unique_ptr<char[]> LoggerJniCallback::format_str(const char* format,
|
|
|
|
va_list ap) const {
|
2017-02-28 00:26:12 +00:00
|
|
|
va_list ap_copy;
|
|
|
|
|
|
|
|
va_copy(ap_copy, ap);
|
2018-04-13 00:55:14 +00:00
|
|
|
const size_t required =
|
|
|
|
vsnprintf(nullptr, 0, format, ap_copy) + 1; // Extra space for '\0'
|
2017-02-28 00:26:12 +00:00
|
|
|
va_end(ap_copy);
|
|
|
|
|
|
|
|
std::unique_ptr<char[]> buf(new char[required]);
|
|
|
|
|
|
|
|
va_copy(ap_copy, ap);
|
|
|
|
vsnprintf(buf.get(), required, format, ap_copy);
|
|
|
|
va_end(ap_copy);
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
2015-02-10 20:59:40 +00:00
|
|
|
LoggerJniCallback::~LoggerJniCallback() {
|
2017-02-28 00:26:12 +00:00
|
|
|
jboolean attached_thread = JNI_FALSE;
|
2017-10-12 18:06:51 +00:00
|
|
|
JNIEnv* env = getJniEnv(&attached_thread);
|
2017-02-28 00:26:12 +00:00
|
|
|
assert(env != nullptr);
|
|
|
|
|
2018-04-13 00:55:14 +00:00
|
|
|
if (m_jdebug_level != nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
env->DeleteGlobalRef(m_jdebug_level);
|
|
|
|
}
|
|
|
|
|
2018-04-13 00:55:14 +00:00
|
|
|
if (m_jinfo_level != nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
env->DeleteGlobalRef(m_jinfo_level);
|
|
|
|
}
|
|
|
|
|
2018-04-13 00:55:14 +00:00
|
|
|
if (m_jwarn_level != nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
env->DeleteGlobalRef(m_jwarn_level);
|
|
|
|
}
|
|
|
|
|
2018-04-13 00:55:14 +00:00
|
|
|
if (m_jerror_level != nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
env->DeleteGlobalRef(m_jerror_level);
|
|
|
|
}
|
|
|
|
|
2018-04-13 00:55:14 +00:00
|
|
|
if (m_jfatal_level != nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
env->DeleteGlobalRef(m_jfatal_level);
|
|
|
|
}
|
2016-07-28 23:54:06 +00:00
|
|
|
|
2018-04-13 00:55:14 +00:00
|
|
|
if (m_jheader_level != nullptr) {
|
2017-02-28 00:26:12 +00:00
|
|
|
env->DeleteGlobalRef(m_jheader_level);
|
|
|
|
}
|
2016-07-28 23:54:06 +00:00
|
|
|
|
2017-10-12 18:06:51 +00:00
|
|
|
releaseJniEnv(attached_thread);
|
2015-02-10 20:59:40 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 20:07:53 +00:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|
2015-02-10 20:59:40 +00:00
|
|
|
|
|
|
|
/*
|
2015-03-10 22:16:21 +00:00
|
|
|
* Class: org_rocksdb_Logger
|
Add native logger support to RocksJava (#12213)
Summary:
## Overview
In this PR, we introduce support for setting the RocksDB native logger through Java. As mentioned in the discussion on the [Google Group discussion](https://groups.google.com/g/rocksdb/c/xYmbEs4sqRM/m/e73E4whJAQAJ), this work is primarily motivated by the JDK 17 [performance regression in JNI thread attach/detach calls](https://bugs.openjdk.org/browse/JDK-8314859): the only existing RocksJava logging configuration call, `setLogger`, invokes the provided logger over the JNI.
## Changes
Specifically, these changes add support for the `devnull` and `stderr` native loggers. For the `stderr` logger, we add the ability to prefix every log with a `logPrefix`, so that it becomes possible know which database a particular log is coming from (if multiple databases are in use). The API looks like the following:
```java
Options opts = new Options();
NativeLogger stderrNativeLogger = NativeLogger.newStderrLogger(
InfoLogLevel.DEBUG_LEVEL, "[my prefix here]");
options.setLogger(stderrNativeLogger);
try (final RocksDB db = RocksDB.open(options, ...)) {...}
// Cleanup
stderrNativeLogger.close()
opts.close();
```
Note that the API to set the logger is the same, via `Options::setLogger` (or `DBOptions::setLogger`). However, it will set the RocksDB logger to be native when the provided logger is an instance of `NativeLogger`.
## Testing
Two tests have been added in `NativeLoggerTest.java`. The first test creates both the `devnull` and `stderr` loggers, and sets them on the associated `Options`. However, to avoid polluting the testing output with logs from `stderr`, only the `devnull` logger is actually used in the test. The second test does the same logic, but for `DBOptions`.
It is possible to manually verify the `stderr` logger by modifying the tests slightly, and observing that the console indeed gets cluttered with logs from `stderr`.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/12213
Reviewed By: cbi42
Differential Revision: D52772306
Pulled By: ajkr
fbshipit-source-id: 4026895f78f9cc250daf6bfa57427957e2d8b053
2024-01-18 01:51:36 +00:00
|
|
|
* Method: newLogger
|
2016-01-20 17:05:41 +00:00
|
|
|
* Signature: (J)J
|
2015-02-10 20:59:40 +00:00
|
|
|
*/
|
Add native logger support to RocksJava (#12213)
Summary:
## Overview
In this PR, we introduce support for setting the RocksDB native logger through Java. As mentioned in the discussion on the [Google Group discussion](https://groups.google.com/g/rocksdb/c/xYmbEs4sqRM/m/e73E4whJAQAJ), this work is primarily motivated by the JDK 17 [performance regression in JNI thread attach/detach calls](https://bugs.openjdk.org/browse/JDK-8314859): the only existing RocksJava logging configuration call, `setLogger`, invokes the provided logger over the JNI.
## Changes
Specifically, these changes add support for the `devnull` and `stderr` native loggers. For the `stderr` logger, we add the ability to prefix every log with a `logPrefix`, so that it becomes possible know which database a particular log is coming from (if multiple databases are in use). The API looks like the following:
```java
Options opts = new Options();
NativeLogger stderrNativeLogger = NativeLogger.newStderrLogger(
InfoLogLevel.DEBUG_LEVEL, "[my prefix here]");
options.setLogger(stderrNativeLogger);
try (final RocksDB db = RocksDB.open(options, ...)) {...}
// Cleanup
stderrNativeLogger.close()
opts.close();
```
Note that the API to set the logger is the same, via `Options::setLogger` (or `DBOptions::setLogger`). However, it will set the RocksDB logger to be native when the provided logger is an instance of `NativeLogger`.
## Testing
Two tests have been added in `NativeLoggerTest.java`. The first test creates both the `devnull` and `stderr` loggers, and sets them on the associated `Options`. However, to avoid polluting the testing output with logs from `stderr`, only the `devnull` logger is actually used in the test. The second test does the same logic, but for `DBOptions`.
It is possible to manually verify the `stderr` logger by modifying the tests slightly, and observing that the console indeed gets cluttered with logs from `stderr`.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/12213
Reviewed By: cbi42
Differential Revision: D52772306
Pulled By: ajkr
fbshipit-source-id: 4026895f78f9cc250daf6bfa57427957e2d8b053
2024-01-18 01:51:36 +00:00
|
|
|
jlong Java_org_rocksdb_Logger_newLogger(JNIEnv* env, jobject jobj,
|
|
|
|
jlong jlog_level) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* sptr_logger = new std::shared_ptr<ROCKSDB_NAMESPACE::LoggerJniCallback>(
|
|
|
|
new ROCKSDB_NAMESPACE::LoggerJniCallback(env, jobj));
|
Add native logger support to RocksJava (#12213)
Summary:
## Overview
In this PR, we introduce support for setting the RocksDB native logger through Java. As mentioned in the discussion on the [Google Group discussion](https://groups.google.com/g/rocksdb/c/xYmbEs4sqRM/m/e73E4whJAQAJ), this work is primarily motivated by the JDK 17 [performance regression in JNI thread attach/detach calls](https://bugs.openjdk.org/browse/JDK-8314859): the only existing RocksJava logging configuration call, `setLogger`, invokes the provided logger over the JNI.
## Changes
Specifically, these changes add support for the `devnull` and `stderr` native loggers. For the `stderr` logger, we add the ability to prefix every log with a `logPrefix`, so that it becomes possible know which database a particular log is coming from (if multiple databases are in use). The API looks like the following:
```java
Options opts = new Options();
NativeLogger stderrNativeLogger = NativeLogger.newStderrLogger(
InfoLogLevel.DEBUG_LEVEL, "[my prefix here]");
options.setLogger(stderrNativeLogger);
try (final RocksDB db = RocksDB.open(options, ...)) {...}
// Cleanup
stderrNativeLogger.close()
opts.close();
```
Note that the API to set the logger is the same, via `Options::setLogger` (or `DBOptions::setLogger`). However, it will set the RocksDB logger to be native when the provided logger is an instance of `NativeLogger`.
## Testing
Two tests have been added in `NativeLoggerTest.java`. The first test creates both the `devnull` and `stderr` loggers, and sets them on the associated `Options`. However, to avoid polluting the testing output with logs from `stderr`, only the `devnull` logger is actually used in the test. The second test does the same logic, but for `DBOptions`.
It is possible to manually verify the `stderr` logger by modifying the tests slightly, and observing that the console indeed gets cluttered with logs from `stderr`.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/12213
Reviewed By: cbi42
Differential Revision: D52772306
Pulled By: ajkr
fbshipit-source-id: 4026895f78f9cc250daf6bfa57427957e2d8b053
2024-01-18 01:51:36 +00:00
|
|
|
auto log_level = static_cast<ROCKSDB_NAMESPACE::InfoLogLevel>(jlog_level);
|
|
|
|
sptr_logger->get()->SetInfoLogLevel(log_level);
|
2022-03-01 17:02:15 +00:00
|
|
|
return GET_CPLUSPLUS_POINTER(sptr_logger);
|
2015-02-10 20:59:40 +00:00
|
|
|
}
|
|
|
|
|
2015-03-10 21:57:15 +00:00
|
|
|
/*
|
2015-03-10 22:16:21 +00:00
|
|
|
* Class: org_rocksdb_Logger
|
2015-03-10 21:57:15 +00:00
|
|
|
* Method: setInfoLogLevel
|
|
|
|
* Signature: (JB)V
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
void Java_org_rocksdb_Logger_setInfoLogLevel(JNIEnv* /*env*/, jobject /*jobj*/,
|
|
|
|
jlong jhandle, jbyte jlog_level) {
|
2017-02-28 00:26:12 +00:00
|
|
|
auto* handle =
|
2020-02-20 20:07:53 +00:00
|
|
|
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::LoggerJniCallback>*>(
|
|
|
|
jhandle);
|
2018-04-13 00:55:14 +00:00
|
|
|
handle->get()->SetInfoLogLevel(
|
2020-02-20 20:07:53 +00:00
|
|
|
static_cast<ROCKSDB_NAMESPACE::InfoLogLevel>(jlog_level));
|
2015-03-10 21:57:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-03-10 22:16:21 +00:00
|
|
|
* Class: org_rocksdb_Logger
|
2015-03-10 21:57:15 +00:00
|
|
|
* Method: infoLogLevel
|
|
|
|
* Signature: (J)B
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
jbyte Java_org_rocksdb_Logger_infoLogLevel(JNIEnv* /*env*/, jobject /*jobj*/,
|
|
|
|
jlong jhandle) {
|
2017-02-28 00:26:12 +00:00
|
|
|
auto* handle =
|
2020-02-20 20:07:53 +00:00
|
|
|
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::LoggerJniCallback>*>(
|
|
|
|
jhandle);
|
2017-02-28 00:26:12 +00:00
|
|
|
return static_cast<jbyte>(handle->get()->GetInfoLogLevel());
|
2015-03-10 21:57:15 +00:00
|
|
|
}
|
|
|
|
|
2015-02-10 20:59:40 +00:00
|
|
|
/*
|
2015-03-10 22:16:21 +00:00
|
|
|
* Class: org_rocksdb_Logger
|
2015-02-10 20:59:40 +00:00
|
|
|
* Method: disposeInternal
|
|
|
|
* Signature: (J)V
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
void Java_org_rocksdb_Logger_disposeInternal(JNIEnv* /*env*/, jobject /*jobj*/,
|
|
|
|
jlong jhandle) {
|
2017-02-28 00:26:12 +00:00
|
|
|
auto* handle =
|
2020-02-20 20:07:53 +00:00
|
|
|
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::LoggerJniCallback>*>(
|
|
|
|
jhandle);
|
2017-02-28 00:26:12 +00:00
|
|
|
delete handle; // delete std::shared_ptr
|
2015-02-10 20:59:40 +00:00
|
|
|
}
|