asherah 1.3.27 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.asherah-version +1 -1
- package/package.json +2 -1
- package/scripts/download-libraries.sh +13 -10
- package/src/asherah.cc +144 -114
- package/src/asherah.d.ts +4 -0
- package/src/cobhan.h +23 -25
- package/src/cobhan_napi_interop.h +54 -59
- package/src/logging.cc +218 -2
- package/src/logging.h +43 -70
- package/SHA256SUMS +0 -4
- package/SHA256SUMS-darwin +0 -4
package/src/logging.h
CHANGED
|
@@ -4,78 +4,51 @@
|
|
|
4
4
|
#include <cstdint>
|
|
5
5
|
#include <iomanip>
|
|
6
6
|
#include <iostream>
|
|
7
|
+
#include <napi.h>
|
|
7
8
|
#include <sstream>
|
|
8
9
|
#include <string>
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const char *message) {
|
|
53
|
-
if (unlikely(verbose_flag)) {
|
|
54
|
-
std::cerr << "asherah-node: [ERROR] " << function_name << ": " << message
|
|
55
|
-
<< std::endl
|
|
56
|
-
<< std::flush;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
__attribute__((always_inline)) inline void error_log(const char *function_name,
|
|
61
|
-
std::string message) {
|
|
62
|
-
if (unlikely(verbose_flag)) {
|
|
63
|
-
std::cerr << "asherah-node: [ERROR] " << function_name << ": " << message
|
|
64
|
-
<< std::endl
|
|
65
|
-
<< std::flush;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
__attribute__((always_inline)) inline std::string format_ptr(char *ptr) {
|
|
70
|
-
std::ostringstream ss;
|
|
71
|
-
ss << "0x" << std::hex << (intptr_t)ptr;
|
|
72
|
-
return ss.str();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
__attribute__((always_inline, noreturn)) inline void
|
|
76
|
-
log_error_and_throw(const char *function_name, std::string error_msg) {
|
|
77
|
-
error_log(function_name, error_msg);
|
|
78
|
-
throw new std::runtime_error(function_name + (": " + error_msg));
|
|
79
|
-
}
|
|
11
|
+
class Logger {
|
|
12
|
+
public:
|
|
13
|
+
Logger();
|
|
14
|
+
Logger(Napi::Function new_log_hook);
|
|
15
|
+
~Logger();
|
|
16
|
+
|
|
17
|
+
void set_log_hook(Napi::Function new_log_hook);
|
|
18
|
+
void set_verbose_flag(int32_t verbose_flag);
|
|
19
|
+
|
|
20
|
+
void debug_log(const char *function_name, const char *message);
|
|
21
|
+
void debug_log(const char *function_name, std::string message);
|
|
22
|
+
void debug_log_alloca(const char *function_name, const char *variable_name,
|
|
23
|
+
size_t length);
|
|
24
|
+
|
|
25
|
+
void debug_log_new(const char *function_name, const char *variable_name,
|
|
26
|
+
size_t length);
|
|
27
|
+
void debug_log_copy_buffer(const char *function_name,
|
|
28
|
+
const char *variable_name, size_t length);
|
|
29
|
+
void debug_log_configure_cbuffer(const char *function_name,
|
|
30
|
+
const char *variable_name, size_t length);
|
|
31
|
+
void error_log(const char *function_name, const char *message);
|
|
32
|
+
void error_log(const char *function_name, std::string message);
|
|
33
|
+
void log_error_and_throw(const char *function_name, std::string error_msg);
|
|
34
|
+
|
|
35
|
+
private:
|
|
36
|
+
void stderr_debug_log(const char *function_name, const char *message);
|
|
37
|
+
void stderr_debug_log(const char *function_name, std::string message);
|
|
38
|
+
void stderr_debug_log_alloca(const char *function_name,
|
|
39
|
+
const char *variable_name, size_t length);
|
|
40
|
+
void stderr_debug_log_new(const char *function_name,
|
|
41
|
+
const char *variable_name, size_t length);
|
|
42
|
+
void stderr_error_log(const char *function_name, const char *message);
|
|
43
|
+
void stderr_error_log(const char *function_name, std::string message);
|
|
44
|
+
|
|
45
|
+
std::string format_ptr(const char *ptr);
|
|
46
|
+
|
|
47
|
+
int32_t verbose_flag = 0;
|
|
48
|
+
Napi::FunctionReference log_hook;
|
|
49
|
+
std::string asherah_node_prefix = "asherah-node: ";
|
|
50
|
+
const int posix_log_level_error = 3;
|
|
51
|
+
const int posix_log_level_debug = 7;
|
|
52
|
+
};
|
|
80
53
|
|
|
81
54
|
#endif
|
package/SHA256SUMS
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
ff15814681dbdc4e153ea4078faae501f7a8031fe2540af1be2a595e19acd8d0 ./libasherah-arm64.h
|
|
2
|
-
6a80183f0b8bbda2578bd8b0b604b6c36e5677cea03b8d6644107feb67386272 ./libasherah-arm64.so
|
|
3
|
-
ff15814681dbdc4e153ea4078faae501f7a8031fe2540af1be2a595e19acd8d0 ./libasherah-x64.h
|
|
4
|
-
13b0f331c99e19ccba7e7a223aa0b6c19135571c19c7e09d0d960c8cbf98d859 ./libasherah-x64.so
|
package/SHA256SUMS-darwin
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
d5e33736becef0c4ae65265210b1f0d2401b167609700f7752e4f545f92962bb ./libasherah-arm64.dylib
|
|
2
|
-
ff15814681dbdc4e153ea4078faae501f7a8031fe2540af1be2a595e19acd8d0 ./libasherah-darwin-arm64.h
|
|
3
|
-
ff15814681dbdc4e153ea4078faae501f7a8031fe2540af1be2a595e19acd8d0 ./libasherah-darwin-x64.h
|
|
4
|
-
ead768fd8ba63c015b9d6b69cf14f66834226d8615bcffea2f76e273b3a1b20c ./libasherah-x64.dylib
|