Skip to content

Commit

Permalink
Merge remote-tracking branch 'couchbase/unstable' into HEAD
Browse files Browse the repository at this point in the history
Change-Id: I5232bbe90fe38ebc3b8c3dcd7945f0678c47d92d
  • Loading branch information
jeelanp2003 committed Sep 21, 2019
2 parents 8c9e60f + 6e7efa3 commit 37a06f0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
14 changes: 0 additions & 14 deletions libs/include/lcb_utils.h
Expand Up @@ -41,19 +41,5 @@ void del_callback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb);

void counter_callback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb);

#define EVT_LOG_MSG_SIZE 1024

void evt_log_formatter(char *buf, int buf_size, const char *subsystem,
int srcline, unsigned int instance_id, const char *fmt,
va_list ap);

LogLevel evt_log_map_level(int severity);

bool evt_should_log(int severity, const char *subsys);

void evt_log_handler(struct lcb_logprocs_st *procs, unsigned int iid,
const char *subsys, int severity, const char *srcfile,
int srcline, const char *fmt, va_list ap);

extern struct lcb_logprocs_st evt_logger;
#endif // COUCHBASE_LCB_UTILS_H
2 changes: 1 addition & 1 deletion libs/query/include/conn-pool.h
Expand Up @@ -49,7 +49,7 @@ class Pool {
void RestoreConnection(lcb_t connection);

private:
Connection::Info CreateConnection();
Connection::Info CreateConnection() const;

v8::Isolate *isolate_;
std::string conn_str_;
Expand Down
11 changes: 10 additions & 1 deletion libs/query/src/conn-pool.cc
Expand Up @@ -18,6 +18,8 @@
#include "log.h"
#include "utils.h"

extern struct lcb_logprocs_st evt_logger;

const char *GetUsernameCached(void *cookie, const char *host, const char *port,
const char *bucket) {
auto isolate = static_cast<v8::Isolate *>(cookie);
Expand Down Expand Up @@ -54,7 +56,7 @@ const char *GetPasswordCached(void *cookie, const char *host, const char *port,
return password;
}

Connection::Info Connection::Pool::CreateConnection() {
Connection::Info Connection::Pool::CreateConnection() const {
std::stringstream error;
lcb_create_st options = {nullptr};
options.version = 3;
Expand All @@ -69,6 +71,13 @@ Connection::Info Connection::Pool::CreateConnection() {
return {true, error.str()};
}

result = lcb_cntl(connection, LCB_CNTL_SET, LCB_CNTL_LOGGER, &evt_logger);
if (result != LCB_SUCCESS) {
error << "Unable to set libcouchbase logger hooks"
<< lcb_strerror(connection, result) << std::endl;
return {true, error.str()};
}

auto auth = lcbauth_new();
result = lcbauth_set_callbacks(auth, isolate_, GetUsernameCached,
GetPasswordCached);
Expand Down
13 changes: 7 additions & 6 deletions libs/src/lcb_util.cc
Expand Up @@ -14,6 +14,8 @@
#include "utils.h"
#include <v8.h>

#define EVT_LOG_MSG_SIZE 1024

const char *GetUsername(void *cookie, const char *host, const char *port,
const char *bucket) {
LOG(logDebug) << "Getting username for host " << RS(host) << " port " << port
Expand Down Expand Up @@ -133,8 +135,6 @@ void counter_callback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb) {
<< lcb_strerror(nullptr, result->rc) << std::endl;
}

#define EVT_LOG_MSG_SIZE 1024

void evt_log_formatter(char *buf, int buf_size, const char *subsystem,
int srcline, unsigned int instance_id, const char *fmt,
va_list ap) {
Expand All @@ -157,14 +157,15 @@ void evt_log_formatter(char *buf, int buf_size, const char *subsystem,
*/
LogLevel evt_log_map_level(int severity) {
switch (severity) {
// TODO : We can anyway not log at these levels as eventing-producer only
// logs at INFO. So, we will log only WARN, ERROR and FATAL messages
case LCB_LOG_TRACE:
return logTrace;
case LCB_LOG_DEBUG:
return logDebug;
case LCB_LOG_INFO:
return logInfo;
// TODO : Map LCB_LOG_INFO to logInfo when MB-36022 is resolved
return logTrace;

case LCB_LOG_WARN:
return logWarning;
case LCB_LOG_ERROR:
case LCB_LOG_FATAL:
default:
Expand Down

0 comments on commit 37a06f0

Please sign in to comment.