Skip to content

Commit

Permalink
Try to take more steps to ensure proper module registration and some …
Browse files Browse the repository at this point in the history
…crude logging, #67
  • Loading branch information
kriszyp committed Oct 28, 2021
1 parent cd8f103 commit 72b3c0b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"target_name": "lmdb-store",
"win_delay_load_hook": "false",
"sources": [
"src/lmdb-store.cpp",
"dependencies/lmdb/libraries/liblmdb/midl.c",
"dependencies/lmdb/libraries/liblmdb/chacha8.c",
"dependencies/lz4/lib/lz4.h",
"dependencies/lz4/lib/lz4.c",
"src/lmdb-store.cpp",
"src/writer.cpp",
"src/env.cpp",
"src/compression.cpp",
Expand Down
22 changes: 19 additions & 3 deletions src/lmdb-store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,24 @@
using namespace v8;
using namespace node;

int Logging::initLogging() {
char* logging = getenv("LMDB_STORE_LOGGING");
if (logging)
fprintf(stderr, "Start logging for lmdb-store\n");
return !!logging;
}
int Logging::debugLogging = Logging::initLogging();

extern "C" NODE_MODULE_EXPORT void
NODE_MODULE_INITIALIZER(Local<Object> exports,
Local<Value> module,
Local<Context> context) {
NODE_MODULE_INITIALIZER(v8::Local<v8::Object> exports,
v8::Local<v8::Value> module,
v8::Local<v8::Context> context);
NODE_MODULE_CONTEXT_AWARE_X(NODE_GYP_MODULE_NAME, NODE_MODULE_INITIALIZER, NULL, 0)
void NODE_MODULE_INITIALIZER(v8::Local<v8::Object> exports,
v8::Local<v8::Value> module,
v8::Local<v8::Context> context) {
if (Logging::debugLogging)
fprintf(stderr, "Start initialization\n");
// Initializes the module
// Export Env as constructor for EnvWrap
EnvWrap::setupExports(exports);
Expand All @@ -16,6 +30,8 @@ NODE_MODULE_INITIALIZER(Local<Object> exports,

// Export misc things
setupExportMisc(exports);
if (Logging::debugLogging)
fprintf(stderr, "Finished initialization\n");
}


Expand Down
6 changes: 5 additions & 1 deletion src/lmdb-store.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ int cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, uint64_t ns);

#endif /* __CPTHREAD_H__ */


class Logging {
public:
static int debugLogging;
static int initLogging();
};

enum class NodeLmdbKeyType {

Expand Down

0 comments on commit 72b3c0b

Please sign in to comment.