Skip to content

Commit

Permalink
refactor jsapi - platform
Browse files Browse the repository at this point in the history
  • Loading branch information
hyj1991 committed Oct 27, 2022
1 parent 5ed0399 commit b87afdc
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 27 deletions.
1 change: 1 addition & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"src/jsapi/export_hooks.cc",
"src/jsapi/export_http.cc",
"src/jsapi/export_thread_logbypass.cc",
"src/jsapi/export_thread_listener.cc",
],
"include_dirs": [
'src',
Expand Down
4 changes: 2 additions & 2 deletions src/commands/send.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "../library/json.hpp"
#include "../platform/platform.h"
#include "library/json.hpp"
#include "platform/platform.h"

namespace xprofiler {
using nlohmann::json;
Expand Down
2 changes: 1 addition & 1 deletion src/jsapi/include/export_thread_logbypass.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "nan.h"

namespace xprofiler {
void RunLogBypass(const Nan::FunctionCallbackInfo<v8::Value>& info);
void CheckSocketPath(const Nan::FunctionCallbackInfo<v8::Value>& info);
}

#endif /* XPROFILER_SRC_JSAPI_THREAD_LOGBYPASS_H */
10 changes: 10 additions & 0 deletions src/jsapi/include/export_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef XPROFILER_SRC_JSAPI_UTILS_H
#define XPROFILER_SRC_JSAPI_UTILS_H

#include "nan.h"

namespace xprofiler {
void RunLogBypass(const Nan::FunctionCallbackInfo<v8::Value>& info);
}

#endif /* XPROFILER_SRC_JSAPI_UTILS_H */
4 changes: 2 additions & 2 deletions src/logbypass/cpu.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "../logger.h"
#include "../platform/platform.h"
#include "logger.h"
#include "platform/platform.h"

namespace xprofiler {
#define EXTRA_SYMBOL
Expand Down
4 changes: 0 additions & 4 deletions src/platform/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <string>

#include "library/writer.h"
#include "nan.h"

namespace xprofiler {

Expand All @@ -29,9 +28,6 @@ void PrintLoadedLibraries(JSONWriter* writer);

// coredumper
void WriteCore(std::string filename);

// js binding
void CheckSocketPath(const Nan::FunctionCallbackInfo<v8::Value>& info);
} // namespace xprofiler

#endif /* XPROFILER_SRC_PLATFORM_PLATFORM_H */
2 changes: 1 addition & 1 deletion src/platform/unix/ipc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <sys/un.h>
#include <unistd.h>

#include "../../logger.h"
#include "logger.h"
#include "configure-inl.h"

namespace xprofiler {
Expand Down
2 changes: 1 addition & 1 deletion src/platform/unix/report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <mach-o/dyld.h>
#endif

#include "../../library/writer.h"
#include "library/writer.h"

extern char** environ;

Expand Down
3 changes: 1 addition & 2 deletions src/platform/unix/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
#include <sys/time.h>
#include <unistd.h>

#include "../platform.h"
#include "uv.h"
#include "platform/platform.h"

namespace xprofiler {
void SleepCrossPlatform(int seconds) { sleep(seconds); }
Expand Down
2 changes: 1 addition & 1 deletion src/platform/win/ipc_win.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifdef _WIN32
#include <windows.h>

#include "../../logger.h"
#include "logger.h"
#include "configure-inl.h"
#include "uv.h"

Expand Down
2 changes: 1 addition & 1 deletion src/platform/win/report_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <sstream>
#include <string>

#include "../../library/writer.h"
#include "library/writer.h"

namespace xprofiler {
using std::ostringstream;
Expand Down
2 changes: 1 addition & 1 deletion src/platform/win/utils_win.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifdef _WIN32
#include <windows.h>

#include "../platform.h"
#include "platform/platform.h"
#include "uv.h"

namespace xprofiler {
Expand Down
22 changes: 11 additions & 11 deletions src/xprofiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "jsapi/include/export_logger.h"
#include "jsapi/include/export_thread_listener.h"
#include "jsapi/include/export_thread_logbypass.h"
#include "jsapi/include/export_utils.h"
#include "library/common.h"
#include "nan.h"
#include "platform/platform.h"
#include "process_data.h"

namespace xprofiler {
Expand All @@ -34,31 +34,31 @@ NAN_MODULE_INIT(Initialize) {
// environment
CREATE_JS_BINDING(setup, JsSetupEnvironmentData);

// set hooks
CREATE_JS_BINDING(setHooks, SetHooks);

// utils
CREATE_JS_BINDING(checkSocketPath, CheckSocketPath);

// config
CREATE_JS_BINDING(configure, Configure);
CREATE_JS_BINDING(getConfig, GetConfig);

// uv thread
CREATE_JS_BINDING(runLogBypass, RunLogBypass);
CREATE_JS_BINDING(runCommandsListener, RunCommandsListener);

// logger
CREATE_JS_BINDING(info, JsInfo);
CREATE_JS_BINDING(error, JsError);
CREATE_JS_BINDING(debug, JsDebug);

// set hooks
CREATE_JS_BINDING(setHooks, SetHooks);

// http status
CREATE_JS_BINDING(addLiveRequest, AddLiveRequest);
CREATE_JS_BINDING(addCloseRequest, AddCloseRequest);
CREATE_JS_BINDING(addSentRequest, AddSentRequest);
CREATE_JS_BINDING(addRequestTimeout, AddRequestTimeout);
CREATE_JS_BINDING(addHttpStatusCode, AddHttpStatusCode);

// performance log
CREATE_JS_BINDING(runLogBypass, RunLogBypass);

// commands listener
CREATE_JS_BINDING(checkSocketPath, CheckSocketPath);
CREATE_JS_BINDING(runCommandsListener, RunCommandsListener);
}

NODE_MODULE_CONTEXT_AWARE(xprofiler, Initialize)
Expand Down

0 comments on commit b87afdc

Please sign in to comment.