marsrs-react-native-xlog 0.1.0-alpha.2 → 0.1.0-alpha.3
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/LICENSE +21 -0
- package/android/build.gradle.kts +1 -1
- package/ios/Frameworks/marsrs-xlog.xcframework/Info.plist +83 -0
- package/ios/Frameworks/marsrs-xlog.xcframework/ios-arm64/Headers/mars_xlog.h +265 -0
- package/ios/Frameworks/marsrs-xlog.xcframework/ios-arm64/Headers/module.modulemap +4 -0
- package/ios/Frameworks/marsrs-xlog.xcframework/ios-arm64/libmars_ffi.a +0 -0
- package/ios/Frameworks/marsrs-xlog.xcframework/ios-arm64_x86_64-simulator/Headers/mars_xlog.h +265 -0
- package/ios/Frameworks/marsrs-xlog.xcframework/ios-arm64_x86_64-simulator/Headers/module.modulemap +4 -0
- package/ios/Frameworks/marsrs-xlog.xcframework/ios-arm64_x86_64-simulator/libmars_ffi.a +0 -0
- package/ios/Frameworks/marsrs-xlog.xcframework/watchos-arm64-simulator/Headers/mars_xlog.h +265 -0
- package/ios/Frameworks/marsrs-xlog.xcframework/watchos-arm64-simulator/Headers/module.modulemap +4 -0
- package/ios/Frameworks/marsrs-xlog.xcframework/watchos-arm64-simulator/libmars_ffi.a +0 -0
- package/ios/Frameworks/marsrs-xlog.xcframework/watchos-arm64_arm64_32/Headers/mars_xlog.h +265 -0
- package/ios/Frameworks/marsrs-xlog.xcframework/watchos-arm64_arm64_32/Headers/module.modulemap +4 -0
- package/ios/Frameworks/marsrs-xlog.xcframework/watchos-arm64_arm64_32/libmars_ffi.a +0 -0
- package/ios/include/mars_xlog.h +265 -0
- package/package.json +1 -1
- package/android/.gradle/9.2.0/checksums/checksums.lock +0 -0
- package/android/.gradle/9.2.0/fileChanges/last-build.bin +0 -0
- package/android/.gradle/9.2.0/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/9.2.0/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/9.2.0/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/* Tencent is pleased to support the open source community by making Mars available.
|
|
2
|
+
* Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the MIT License (the "License"); you may not use this file except in
|
|
5
|
+
* compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
* http://opensource.org/licenses/MIT
|
|
7
|
+
*
|
|
8
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License is
|
|
9
|
+
* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
10
|
+
* either express or implied. See the License for the specific language governing permissions and
|
|
11
|
+
* limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* mars_xlog.h — C ABI of the Rust xlog implementation (`marsrs-ffi`).
|
|
16
|
+
*
|
|
17
|
+
* This header is the drop-in seam for the existing C++ / JNI / ObjC layers of
|
|
18
|
+
* Mars. It mirrors the C++ surface of
|
|
19
|
+
*
|
|
20
|
+
* mars/xlog/appender.h (mars::xlog::appender_open / flush / close ...)
|
|
21
|
+
* mars/xlog/xlogger_interface.h (mars::xlog::XloggerWrite / SetLevel ...)
|
|
22
|
+
* mars/comm/xlogger/xloggerbase.h (TLogLevel)
|
|
23
|
+
*
|
|
24
|
+
* and is the C equivalent of the JNI bridge in mars/xlog/jni/Java2C_Xlog.cc.
|
|
25
|
+
*
|
|
26
|
+
* The header is hand-written and checked in next to the crate so that a C/C++
|
|
27
|
+
* caller can include it without running cbindgen. It is kept in sync with
|
|
28
|
+
* `src/abi.rs` by `tests/header_sync.rs`.
|
|
29
|
+
*
|
|
30
|
+
* Threading: every symbol may be called from any thread. `mars_xlog_open`,
|
|
31
|
+
* `mars_xlog_close` and the setters mutate process-wide state (exactly like the
|
|
32
|
+
* C++ globals) and should be called from one place during start-up / shut-down.
|
|
33
|
+
*
|
|
34
|
+
* Panics: no Rust panic ever crosses this boundary. Every entry point is
|
|
35
|
+
* wrapped in `catch_unwind`; a panic is reported as `MARS_XLOG_ERR_PANIC` (or
|
|
36
|
+
* silently swallowed for the `void` symbols).
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
#ifndef MARS_XLOG_H_
|
|
40
|
+
#define MARS_XLOG_H_
|
|
41
|
+
|
|
42
|
+
/* --- enums ------------------------------------------------------------- */
|
|
43
|
+
|
|
44
|
+
/** Mirrors `mars::xlog::TAppenderMode` (appender.h). */
|
|
45
|
+
typedef enum { MarsAppenderAsync = 0, MarsAppenderSync = 1 } MarsAppenderMode;
|
|
46
|
+
|
|
47
|
+
/** Mirrors `mars::xlog::TCompressMode` (appender.h). */
|
|
48
|
+
typedef enum { MarsCompressZlib = 0, MarsCompressZstd = 1 } MarsCompressMode;
|
|
49
|
+
|
|
50
|
+
/** Mirrors `TLogLevel` (xloggerbase.h); `kLevelAll == kLevelVerbose == 0`. */
|
|
51
|
+
typedef enum {
|
|
52
|
+
MarsLevelVerbose = 0,
|
|
53
|
+
MarsLevelDebug = 1,
|
|
54
|
+
MarsLevelInfo = 2,
|
|
55
|
+
MarsLevelWarn = 3,
|
|
56
|
+
MarsLevelError = 4,
|
|
57
|
+
MarsLevelFatal = 5
|
|
58
|
+
} MarsLogLevel;
|
|
59
|
+
|
|
60
|
+
/** Additional level understood only by the filter: disables every record. */
|
|
61
|
+
#define MARS_LEVEL_NONE 6
|
|
62
|
+
|
|
63
|
+
/* --- return codes ------------------------------------------------------- */
|
|
64
|
+
|
|
65
|
+
#define MARS_XLOG_OK 0
|
|
66
|
+
#define MARS_XLOG_ERR_NULL_CONFIG (-1) /* `config` was NULL */
|
|
67
|
+
#define MARS_XLOG_ERR_BAD_MODE (-2) /* `mode` outside MarsAppenderMode */
|
|
68
|
+
#define MARS_XLOG_ERR_BAD_COMPRESS (-3) /* `compress_mode` outside MarsCompressMode */
|
|
69
|
+
#define MARS_XLOG_ERR_EMPTY_LOG_DIR (-4) /* `log_dir` was NULL or "" */
|
|
70
|
+
#define MARS_XLOG_ERR_APPENDER (-5) /* the Rust appender refused the config */
|
|
71
|
+
#define MARS_XLOG_ERR_NULL_OUT (-6) /* `out` was NULL */
|
|
72
|
+
#define MARS_XLOG_ERR_NO_SPACE (-7) /* output buffer too small (0 or < need) */
|
|
73
|
+
#define MARS_XLOG_ERR_NO_PATH (-8) /* no current log file is open */
|
|
74
|
+
#define MARS_XLOG_ERR_PANIC (-99) /* a Rust panic was caught at the boundary */
|
|
75
|
+
|
|
76
|
+
/* --- `mars_xlog_oneshot_flush` result: mars::xlog::TFileIOAction --------- */
|
|
77
|
+
|
|
78
|
+
#define MARS_XLOG_ACTION_NONE 0
|
|
79
|
+
#define MARS_XLOG_ACTION_SUCCESS 1
|
|
80
|
+
#define MARS_XLOG_ACTION_UNNECESSARY 2 /* there was nothing to flush */
|
|
81
|
+
#define MARS_XLOG_ACTION_OPEN_FAILED 3
|
|
82
|
+
#define MARS_XLOG_ACTION_READ_FAILED 4
|
|
83
|
+
#define MARS_XLOG_ACTION_WRITE_FAILED 5
|
|
84
|
+
#define MARS_XLOG_ACTION_CLOSE_FAILED 6
|
|
85
|
+
#define MARS_XLOG_ACTION_REMOVE_FAILED 7
|
|
86
|
+
|
|
87
|
+
/* --- config ------------------------------------------------------------- */
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Mirrors `mars::xlog::XLogConfig` (appender.h) with C strings instead of
|
|
91
|
+
* `std::string`. Every pointer must be NUL-terminated UTF-8 or NULL; NULL is
|
|
92
|
+
* treated as "empty" (see the field docs) except for `log_dir`, which is
|
|
93
|
+
* mandatory.
|
|
94
|
+
*/
|
|
95
|
+
typedef struct {
|
|
96
|
+
int mode; /* MarsAppenderMode; default when unset: Async */
|
|
97
|
+
const char* log_dir; /* mandatory, directory is created if missing */
|
|
98
|
+
const char* name_prefix; /* used verbatim; no default, as in C++ */
|
|
99
|
+
const char* pub_key; /* NULL / "" => logs are written unencrypted */
|
|
100
|
+
int compress_mode; /* MarsCompressMode; default when unset: Zlib */
|
|
101
|
+
int compress_level; /* <= 0 => keep the appender default (6) */
|
|
102
|
+
const char* cache_dir; /* NULL / "" => the mmap cache lives in log_dir */
|
|
103
|
+
int cache_days; /* < 0 => 0; 0 => keep every file */
|
|
104
|
+
} MarsXLogConfig;
|
|
105
|
+
|
|
106
|
+
/* --- lifecycle ---------------------------------------------------------- */
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Replaces `mars::xlog::appender_open(const XLogConfig&)`.
|
|
110
|
+
*
|
|
111
|
+
* @return MARS_XLOG_OK (0) on success, or a negative MARS_XLOG_ERR_* code.
|
|
112
|
+
*/
|
|
113
|
+
int mars_xlog_open(const MarsXLogConfig* config);
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Replaces `mars::xlog::XloggerWrite(...)` / `appender_write`. The record is
|
|
117
|
+
* dropped (cheaply, before any formatting) when `level` is below the level set
|
|
118
|
+
* by `mars_xlog_set_level`.
|
|
119
|
+
*
|
|
120
|
+
* `tag`, `filename`, `func_name` and `message` may be NULL; NULL and invalid
|
|
121
|
+
* UTF-8 are treated as an empty string.
|
|
122
|
+
*/
|
|
123
|
+
void mars_xlog_write(int level,
|
|
124
|
+
const char* tag,
|
|
125
|
+
const char* filename,
|
|
126
|
+
const char* func_name,
|
|
127
|
+
int line,
|
|
128
|
+
const char* message);
|
|
129
|
+
|
|
130
|
+
/** Replaces `mars::xlog::appender_flush()` — signals the writer thread. */
|
|
131
|
+
void mars_xlog_flush(void);
|
|
132
|
+
|
|
133
|
+
/** Replaces `mars::xlog::appender_flush_sync()` — flushes and waits. */
|
|
134
|
+
void mars_xlog_flush_sync(void);
|
|
135
|
+
|
|
136
|
+
/** Replaces `mars::xlog::appender_close()`. */
|
|
137
|
+
void mars_xlog_close(void);
|
|
138
|
+
|
|
139
|
+
/** Replaces `xlogger_SetLevel()`; `level` < 0 clamps to Verbose. */
|
|
140
|
+
void mars_xlog_set_level(int level);
|
|
141
|
+
|
|
142
|
+
/** Replaces `appender_set_console_log(bool)`; `open` != 0 means on. */
|
|
143
|
+
void mars_xlog_set_console_log(int open);
|
|
144
|
+
|
|
145
|
+
/** Replaces `appender_set_max_file_size(uint64_t)`; 0 means "do not split". */
|
|
146
|
+
void mars_xlog_set_max_file_size(unsigned long long bytes);
|
|
147
|
+
|
|
148
|
+
/** Replaces `appender_set_max_alive_duration(long)`; negative clamps to 0. */
|
|
149
|
+
void mars_xlog_set_max_alive_duration(long long seconds);
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Replaces `appender_get_current_log_path(char*, unsigned int)`.
|
|
153
|
+
*
|
|
154
|
+
* Writes the NUL-terminated path of the log file currently being appended to
|
|
155
|
+
* into `out` (which must hold at least `len` bytes).
|
|
156
|
+
*
|
|
157
|
+
* @return the number of bytes written excluding the terminating NUL, or a
|
|
158
|
+
* negative MARS_XLOG_ERR_* code (`MARS_XLOG_ERR_NULL_OUT`,
|
|
159
|
+
* `MARS_XLOG_ERR_NO_SPACE`, `MARS_XLOG_ERR_NO_PATH`).
|
|
160
|
+
*/
|
|
161
|
+
int mars_xlog_current_log_path(char* out, unsigned int len);
|
|
162
|
+
|
|
163
|
+
/* ---- logger instances (mars::xlog::NewXloggerInstance and friends) ----
|
|
164
|
+
*
|
|
165
|
+
* Each instance owns an appender: its own log directory, prefix, key, mode and
|
|
166
|
+
* cache file. Handle 0 means "the process-wide appender opened by
|
|
167
|
+
* mars_xlog_open".
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
/* Returns the instance handle, or 0 on a null/invalid config. */
|
|
171
|
+
long long mars_xlog_new_instance(const MarsXLogConfig* config, int level);
|
|
172
|
+
|
|
173
|
+
/* The handle registered for name_prefix, or 0 when there is none. */
|
|
174
|
+
long long mars_xlog_get_instance(const char* name_prefix);
|
|
175
|
+
|
|
176
|
+
/* Releases the instance and closes its appender. */
|
|
177
|
+
void mars_xlog_release_instance(const char* name_prefix);
|
|
178
|
+
|
|
179
|
+
/* Writes through an instance; honours the instance's level. */
|
|
180
|
+
void mars_xlog_write_instance(long long instance,
|
|
181
|
+
int level,
|
|
182
|
+
const char* tag,
|
|
183
|
+
const char* filename,
|
|
184
|
+
const char* func_name,
|
|
185
|
+
int line,
|
|
186
|
+
const char* log);
|
|
187
|
+
|
|
188
|
+
/* 1 when the instance would write this level, 0 otherwise. */
|
|
189
|
+
int mars_xlog_is_enabled_for(long long instance, int level);
|
|
190
|
+
|
|
191
|
+
/* The instance's level, or -1 for an unknown handle. */
|
|
192
|
+
int mars_xlog_get_level(long long instance);
|
|
193
|
+
|
|
194
|
+
/* SetLevel for an instance (0 = the default logger). */
|
|
195
|
+
void mars_xlog_set_level_instance(long long instance, int level);
|
|
196
|
+
|
|
197
|
+
/* appender_setmode: switches the process-wide appender between async/sync. */
|
|
198
|
+
void mars_xlog_set_mode(int mode);
|
|
199
|
+
|
|
200
|
+
/* SetAppenderMode for an instance. */
|
|
201
|
+
void mars_xlog_set_mode_instance(long long instance, int mode);
|
|
202
|
+
|
|
203
|
+
/* Drains an instance; sync != 0 waits for the write to complete. */
|
|
204
|
+
void mars_xlog_flush_instance(long long instance, int sync);
|
|
205
|
+
|
|
206
|
+
/* FlushAll: drains the process-wide appender *and* every instance. */
|
|
207
|
+
void mars_xlog_flush_all(int sync);
|
|
208
|
+
|
|
209
|
+
/* SetConsoleLogOpen for an instance (0 = the default logger). */
|
|
210
|
+
void mars_xlog_set_console_log_instance(long long instance, int open);
|
|
211
|
+
|
|
212
|
+
/* SetMaxFileSize for an instance; 0 means "do not split". */
|
|
213
|
+
void mars_xlog_set_max_file_size_instance(long long instance, unsigned long long bytes);
|
|
214
|
+
|
|
215
|
+
/* SetMaxAliveTime for an instance; negative clamps to 0. */
|
|
216
|
+
void mars_xlog_set_max_alive_duration_instance(long long instance, long long seconds);
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Replaces `mars::xlog::appender_oneshot_flush()`: drains the
|
|
220
|
+
* `<prefix>[_<n>].mmap3` cache files another process left behind, without
|
|
221
|
+
* opening an appender. The ones a live writer of this process — or of any
|
|
222
|
+
* other — still holds are left alone, so it answers
|
|
223
|
+
* MARS_XLOG_ACTION_UNNECESSARY when there is nothing of a dead process's to
|
|
224
|
+
* recover.
|
|
225
|
+
*
|
|
226
|
+
* @return one of the MARS_XLOG_ACTION_* values (0..7), or a negative
|
|
227
|
+
* MARS_XLOG_ERR_* code when `config` is unusable.
|
|
228
|
+
*/
|
|
229
|
+
int mars_xlog_oneshot_flush(const MarsXLogConfig* config);
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Replaces `mars::xlog::appender_make_logfile_name()`: the log file *name* for
|
|
233
|
+
* the day `timespan` days ago (0 = today), whether or not it exists yet.
|
|
234
|
+
*
|
|
235
|
+
* The C++ fills a `std::vector`; a C caller walks the same list with `index`,
|
|
236
|
+
* starting at 0 and stopping at MARS_XLOG_ERR_NO_PATH. `prefix` and `log_dir`
|
|
237
|
+
* may be NULL (an empty `log_dir` yields no name at all).
|
|
238
|
+
*
|
|
239
|
+
* @return the number of bytes written excluding the terminating NUL, or a
|
|
240
|
+
* negative MARS_XLOG_ERR_* code.
|
|
241
|
+
*/
|
|
242
|
+
int mars_xlog_make_logfile_name(int timespan,
|
|
243
|
+
const char* prefix,
|
|
244
|
+
const char* log_dir,
|
|
245
|
+
unsigned int index,
|
|
246
|
+
char* out,
|
|
247
|
+
unsigned int len);
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Replaces `mars::xlog::appender_getfilepath_from_timespan()`: the log files
|
|
251
|
+
* that *exist* for the day `timespan` days ago. Same `index` protocol as
|
|
252
|
+
* mars_xlog_make_logfile_name.
|
|
253
|
+
*/
|
|
254
|
+
int mars_xlog_getfilepath_from_timespan(int timespan,
|
|
255
|
+
const char* prefix,
|
|
256
|
+
const char* log_dir,
|
|
257
|
+
unsigned int index,
|
|
258
|
+
char* out,
|
|
259
|
+
unsigned int len);
|
|
260
|
+
|
|
261
|
+
/* The cache directory, or a negative MARS_XLOG_ERR_* code. */
|
|
262
|
+
int mars_xlog_current_log_cache_path(char* out, unsigned int len);
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
#endif /* MARS_XLOG_H_ */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marsrs-react-native-xlog",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.3",
|
|
4
4
|
"description": "React Native module for xlog, the logging half of mars-rs: a Rust implementation of Tencent/mars that writes the .xlog the C++ implementation produced.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/orangeboyChen/mars-rs",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|