couchbase 4.2.8-dev.1 → 4.2.8

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -54,7 +54,7 @@
54
54
  "type": "git",
55
55
  "url": "http://github.com/couchbase/couchnode.git"
56
56
  },
57
- "version": "4.2.8-dev.1",
57
+ "version": "4.2.8",
58
58
  "config": {
59
59
  "native": false
60
60
  },
@@ -79,12 +79,12 @@
79
79
  ]
80
80
  },
81
81
  "optionalDependencies": {
82
- "@couchbase/couchbase-darwin-arm64-napi": "4.2.8-dev.1",
83
- "@couchbase/couchbase-darwin-x64-napi": "4.2.8-dev.1",
84
- "@couchbase/couchbase-linux-arm64-napi": "4.2.8-dev.1",
85
- "@couchbase/couchbase-linuxmusl-x64-napi": "4.2.8-dev.1",
86
- "@couchbase/couchbase-linux-x64-napi": "4.2.8-dev.1",
87
- "@couchbase/couchbase-win32-x64-napi": "4.2.8-dev.1"
82
+ "@couchbase/couchbase-darwin-arm64-napi": "4.2.8",
83
+ "@couchbase/couchbase-darwin-x64-napi": "4.2.8",
84
+ "@couchbase/couchbase-linux-arm64-napi": "4.2.8",
85
+ "@couchbase/couchbase-linuxmusl-x64-napi": "4.2.8",
86
+ "@couchbase/couchbase-linux-x64-napi": "4.2.8",
87
+ "@couchbase/couchbase-win32-x64-napi": "4.2.8"
88
88
  },
89
89
  "files": [
90
90
  "LICENSE",
@@ -1,23 +0,0 @@
1
- # Copyright(c) 2019 spdlog authors Distributed under the MIT License (http://opensource.org/licenses/MIT)
2
-
3
- cmake_minimum_required(VERSION 3.10)
4
- project(spdlog_examples CXX)
5
-
6
- if(NOT TARGET spdlog)
7
- # Stand-alone build
8
- find_package(spdlog REQUIRED)
9
- endif()
10
-
11
- # ---------------------------------------------------------------------------------------
12
- # Example of using pre-compiled library
13
- # ---------------------------------------------------------------------------------------
14
- add_executable(example example.cpp)
15
- target_link_libraries(example PRIVATE spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32>)
16
-
17
- # ---------------------------------------------------------------------------------------
18
- # Example of using header-only library
19
- # ---------------------------------------------------------------------------------------
20
- if(SPDLOG_BUILD_EXAMPLE_HO)
21
- add_executable(example_header_only example.cpp)
22
- target_link_libraries(example_header_only PRIVATE spdlog::spdlog_header_only)
23
- endif()
@@ -1,398 +0,0 @@
1
- //
2
- // Copyright(c) 2015 Gabi Melman.
3
- // Distributed under the MIT License (http://opensource.org/licenses/MIT)
4
-
5
- // spdlog usage example
6
-
7
- #include <cstdio>
8
- #include <chrono>
9
-
10
- void load_levels_example();
11
- void stdout_logger_example();
12
- void basic_example();
13
- void rotating_example();
14
- void daily_example();
15
- void callback_example();
16
- void async_example();
17
- void binary_example();
18
- void vector_example();
19
- void stopwatch_example();
20
- void trace_example();
21
- void multi_sink_example();
22
- void user_defined_example();
23
- void err_handler_example();
24
- void syslog_example();
25
- void udp_example();
26
- void custom_flags_example();
27
- void file_events_example();
28
- void replace_default_logger_example();
29
-
30
- #include "spdlog/spdlog.h"
31
- #include "spdlog/cfg/env.h" // support for loading levels from the environment variable
32
- #include "spdlog/fmt/ostr.h" // support for user defined types
33
-
34
-
35
- int main(int, char *[])
36
- {
37
- // Log levels can be loaded from argv/env using "SPDLOG_LEVEL"
38
- load_levels_example();
39
-
40
- spdlog::info("Welcome to spdlog version {}.{}.{} !", SPDLOG_VER_MAJOR, SPDLOG_VER_MINOR, SPDLOG_VER_PATCH);
41
-
42
- spdlog::warn("Easy padding in numbers like {:08d}", 12);
43
- spdlog::critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
44
- spdlog::info("Support for floats {:03.2f}", 1.23456);
45
- spdlog::info("Positional args are {1} {0}..", "too", "supported");
46
- spdlog::info("{:>8} aligned, {:<8} aligned", "right", "left");
47
-
48
- // Runtime log levels
49
- spdlog::set_level(spdlog::level::info); // Set global log level to info
50
- spdlog::debug("This message should not be displayed!");
51
- spdlog::set_level(spdlog::level::trace); // Set specific logger's log level
52
- spdlog::debug("This message should be displayed..");
53
-
54
- // Customize msg format for all loggers
55
- spdlog::set_pattern("[%H:%M:%S %z] [%^%L%$] [thread %t] %v");
56
- spdlog::info("This an info message with custom format");
57
- spdlog::set_pattern("%+"); // back to default format
58
- spdlog::set_level(spdlog::level::info);
59
-
60
- // Backtrace support
61
- // Loggers can store in a ring buffer all messages (including debug/trace) for later inspection.
62
- // When needed, call dump_backtrace() to see what happened:
63
- spdlog::enable_backtrace(10); // create ring buffer with capacity of 10 messages
64
- for (int i = 0; i < 100; i++)
65
- {
66
- spdlog::debug("Backtrace message {}", i); // not logged..
67
- }
68
- // e.g. if some error happened:
69
- spdlog::dump_backtrace(); // log them now!
70
-
71
- try
72
- {
73
- stdout_logger_example();
74
- basic_example();
75
- rotating_example();
76
- daily_example();
77
- callback_example();
78
- async_example();
79
- binary_example();
80
- vector_example();
81
- multi_sink_example();
82
- user_defined_example();
83
- err_handler_example();
84
- trace_example();
85
- stopwatch_example();
86
- udp_example();
87
- custom_flags_example();
88
- file_events_example();
89
- replace_default_logger_example();
90
-
91
- // Flush all *registered* loggers using a worker thread every 3 seconds.
92
- // note: registered loggers *must* be thread safe for this to work correctly!
93
- spdlog::flush_every(std::chrono::seconds(3));
94
-
95
- // Apply some function on all registered loggers
96
- spdlog::apply_all([&](std::shared_ptr<spdlog::logger> l) { l->info("End of example."); });
97
-
98
- // Release all spdlog resources, and drop all loggers in the registry.
99
- // This is optional (only mandatory if using windows + async log).
100
- spdlog::shutdown();
101
- }
102
-
103
- // Exceptions will only be thrown upon failed logger or sink construction (not during logging).
104
- catch (const spdlog::spdlog_ex &ex)
105
- {
106
- std::printf("Log initialization failed: %s\n", ex.what());
107
- return 1;
108
- }
109
- }
110
-
111
- #include "spdlog/sinks/stdout_color_sinks.h"
112
- // or #include "spdlog/sinks/stdout_sinks.h" if no colors needed.
113
- void stdout_logger_example()
114
- {
115
- // Create color multi threaded logger.
116
- auto console = spdlog::stdout_color_mt("console");
117
- // or for stderr:
118
- // auto console = spdlog::stderr_color_mt("error-logger");
119
- }
120
-
121
- #include "spdlog/sinks/basic_file_sink.h"
122
- void basic_example()
123
- {
124
- // Create basic file logger (not rotated).
125
- auto my_logger = spdlog::basic_logger_mt("file_logger", "logs/basic-log.txt", true);
126
- }
127
-
128
- #include "spdlog/sinks/rotating_file_sink.h"
129
- void rotating_example()
130
- {
131
- // Create a file rotating logger with 5mb size max and 3 rotated files.
132
- auto rotating_logger = spdlog::rotating_logger_mt("some_logger_name", "logs/rotating.txt", 1048576 * 5, 3);
133
- }
134
-
135
- #include "spdlog/sinks/daily_file_sink.h"
136
- void daily_example()
137
- {
138
- // Create a daily logger - a new file is created every day on 2:30am.
139
- auto daily_logger = spdlog::daily_logger_mt("daily_logger", "logs/daily.txt", 2, 30);
140
- }
141
-
142
- #include "spdlog/sinks/callback_sink.h"
143
- void callback_example()
144
- {
145
- // Create the logger
146
- auto logger = spdlog::callback_logger_mt("custom_callback_logger", [](const spdlog::details::log_msg & /*msg*/) {
147
- // do what you need to do with msg
148
- });
149
- }
150
-
151
- #include "spdlog/cfg/env.h"
152
- void load_levels_example()
153
- {
154
- // Set the log level to "info" and mylogger to "trace":
155
- // SPDLOG_LEVEL=info,mylogger=trace && ./example
156
- spdlog::cfg::load_env_levels();
157
- // or from command line:
158
- // ./example SPDLOG_LEVEL=info,mylogger=trace
159
- // #include "spdlog/cfg/argv.h" // for loading levels from argv
160
- // spdlog::cfg::load_argv_levels(args, argv);
161
- }
162
-
163
- #include "spdlog/async.h"
164
- void async_example()
165
- {
166
- // Default thread pool settings can be modified *before* creating the async logger:
167
- // spdlog::init_thread_pool(32768, 1); // queue with max 32k items 1 backing thread.
168
- auto async_file = spdlog::basic_logger_mt<spdlog::async_factory>("async_file_logger", "logs/async_log.txt");
169
- // alternatively:
170
- // auto async_file = spdlog::create_async<spdlog::sinks::basic_file_sink_mt>("async_file_logger", "logs/async_log.txt");
171
-
172
- for (int i = 1; i < 101; ++i)
173
- {
174
- async_file->info("Async message #{}", i);
175
- }
176
- }
177
-
178
- // Log binary data as hex.
179
- // Many types of std::container<char> types can be used.
180
- // Iterator ranges are supported too.
181
- // Format flags:
182
- // {:X} - print in uppercase.
183
- // {:s} - don't separate each byte with space.
184
- // {:p} - don't print the position on each line start.
185
- // {:n} - don't split the output to lines.
186
-
187
- #if !defined SPDLOG_USE_STD_FORMAT || defined(_MSC_VER)
188
- #include "spdlog/fmt/bin_to_hex.h"
189
- void binary_example()
190
- {
191
- std::vector<char> buf(80);
192
- for (int i = 0; i < 80; i++)
193
- {
194
- buf.push_back(static_cast<char>(i & 0xff));
195
- }
196
- spdlog::info("Binary example: {}", spdlog::to_hex(buf));
197
- spdlog::info("Another binary example:{:n}", spdlog::to_hex(std::begin(buf), std::begin(buf) + 10));
198
- // more examples:
199
- // logger->info("uppercase: {:X}", spdlog::to_hex(buf));
200
- // logger->info("uppercase, no delimiters: {:Xs}", spdlog::to_hex(buf));
201
- // logger->info("uppercase, no delimiters, no position info: {:Xsp}", spdlog::to_hex(buf));
202
- // logger->info("hexdump style: {:a}", spdlog::to_hex(buf));
203
- // logger->info("hexdump style, 20 chars per line {:a}", spdlog::to_hex(buf, 20));
204
- }
205
- #else
206
- void binary_example() {
207
- // not supported with std::format yet
208
- }
209
- #endif
210
-
211
- // Log a vector of numbers
212
- #ifndef SPDLOG_USE_STD_FORMAT
213
- # include "spdlog/fmt/ranges.h"
214
- void vector_example()
215
- {
216
- std::vector<int> vec = {1, 2, 3};
217
- spdlog::info("Vector example: {}", vec);
218
- }
219
-
220
- #else
221
- void vector_example() {}
222
- #endif
223
-
224
- // ! DSPDLOG_USE_STD_FORMAT
225
-
226
- // Compile time log levels.
227
- // define SPDLOG_ACTIVE_LEVEL to required level (e.g. SPDLOG_LEVEL_TRACE)
228
- void trace_example()
229
- {
230
- // trace from default logger
231
- SPDLOG_TRACE("Some trace message.. {} ,{}", 1, 3.23);
232
- // debug from default logger
233
- SPDLOG_DEBUG("Some debug message.. {} ,{}", 1, 3.23);
234
-
235
- // trace from logger object
236
- auto logger = spdlog::get("file_logger");
237
- SPDLOG_LOGGER_TRACE(logger, "another trace message");
238
- }
239
-
240
- // stopwatch example
241
- #include "spdlog/stopwatch.h"
242
- #include <thread>
243
- void stopwatch_example()
244
- {
245
- spdlog::stopwatch sw;
246
- std::this_thread::sleep_for(std::chrono::milliseconds(123));
247
- spdlog::info("Stopwatch: {} seconds", sw);
248
- }
249
-
250
- #include "spdlog/sinks/udp_sink.h"
251
- void udp_example()
252
- {
253
- spdlog::sinks::udp_sink_config cfg("127.0.0.1", 11091);
254
- auto my_logger = spdlog::udp_logger_mt("udplog", cfg);
255
- my_logger->set_level(spdlog::level::debug);
256
- my_logger->info("hello world");
257
- }
258
-
259
- // A logger with multiple sinks (stdout and file) - each with a different format and log level.
260
- void multi_sink_example()
261
- {
262
- auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
263
- console_sink->set_level(spdlog::level::warn);
264
- console_sink->set_pattern("[multi_sink_example] [%^%l%$] %v");
265
-
266
- auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("logs/multisink.txt", true);
267
- file_sink->set_level(spdlog::level::trace);
268
-
269
- spdlog::logger logger("multi_sink", {console_sink, file_sink});
270
- logger.set_level(spdlog::level::debug);
271
- logger.warn("this should appear in both console and file");
272
- logger.info("this message should not appear in the console, only in the file");
273
- }
274
-
275
- // User defined types logging
276
- struct my_type
277
- {
278
- int i = 0;
279
- explicit my_type(int i)
280
- : i(i){};
281
- };
282
-
283
- #ifndef SPDLOG_USE_STD_FORMAT // when using fmtlib
284
- template<>
285
- struct fmt::formatter<my_type> : fmt::formatter<std::string>
286
- {
287
- auto format(my_type my, format_context &ctx) -> decltype(ctx.out())
288
- {
289
- return fmt::format_to(ctx.out(), "[my_type i={}]", my.i);
290
- }
291
- };
292
-
293
- #else // when using std::format
294
- template<>
295
- struct std::formatter<my_type> : std::formatter<std::string>
296
- {
297
- auto format(my_type my, format_context &ctx) const -> decltype(ctx.out())
298
- {
299
- return format_to(ctx.out(), "[my_type i={}]", my.i);
300
- }
301
- };
302
- #endif
303
-
304
- void user_defined_example()
305
- {
306
- spdlog::info("user defined type: {}", my_type(14));
307
- }
308
-
309
- // Custom error handler. Will be triggered on log failure.
310
- void err_handler_example()
311
- {
312
- // can be set globally or per logger(logger->set_error_handler(..))
313
- spdlog::set_error_handler([](const std::string &msg) { printf("*** Custom log error handler: %s ***\n", msg.c_str()); });
314
- }
315
-
316
- // syslog example (linux/osx/freebsd)
317
- #ifndef _WIN32
318
- # include "spdlog/sinks/syslog_sink.h"
319
- void syslog_example()
320
- {
321
- std::string ident = "spdlog-example";
322
- auto syslog_logger = spdlog::syslog_logger_mt("syslog", ident, LOG_PID);
323
- syslog_logger->warn("This is warning that will end up in syslog.");
324
- }
325
- #endif
326
-
327
- // Android example.
328
- #if defined(__ANDROID__)
329
- # include "spdlog/sinks/android_sink.h"
330
- void android_example()
331
- {
332
- std::string tag = "spdlog-android";
333
- auto android_logger = spdlog::android_logger_mt("android", tag);
334
- android_logger->critical("Use \"adb shell logcat\" to view this message.");
335
- }
336
- #endif
337
-
338
- // Log patterns can contain custom flags.
339
- // this will add custom flag '%*' which will be bound to a <my_formatter_flag> instance
340
- #include "spdlog/pattern_formatter.h"
341
- class my_formatter_flag : public spdlog::custom_flag_formatter
342
- {
343
- public:
344
- void format(const spdlog::details::log_msg &, const std::tm &, spdlog::memory_buf_t &dest) override
345
- {
346
- std::string some_txt = "custom-flag";
347
- dest.append(some_txt.data(), some_txt.data() + some_txt.size());
348
- }
349
-
350
- std::unique_ptr<custom_flag_formatter> clone() const override
351
- {
352
- return spdlog::details::make_unique<my_formatter_flag>();
353
- }
354
- };
355
-
356
- void custom_flags_example()
357
- {
358
-
359
- using spdlog::details::make_unique; // for pre c++14
360
- auto formatter = make_unique<spdlog::pattern_formatter>();
361
- formatter->add_flag<my_formatter_flag>('*').set_pattern("[%n] [%*] [%^%l%$] %v");
362
- // set the new formatter using spdlog::set_formatter(formatter) or logger->set_formatter(formatter)
363
- // spdlog::set_formatter(std::move(formatter));
364
- }
365
-
366
- void file_events_example()
367
- {
368
- // pass the spdlog::file_event_handlers to file sinks for open/close log file notifications
369
- spdlog::file_event_handlers handlers;
370
- handlers.before_open = [](spdlog::filename_t filename) { spdlog::info("Before opening {}", filename); };
371
- handlers.after_open = [](spdlog::filename_t filename, std::FILE *fstream) {
372
- spdlog::info("After opening {}", filename);
373
- fputs("After opening\n", fstream);
374
- };
375
- handlers.before_close = [](spdlog::filename_t filename, std::FILE *fstream) {
376
- spdlog::info("Before closing {}", filename);
377
- fputs("Before closing\n", fstream);
378
- };
379
- handlers.after_close = [](spdlog::filename_t filename) { spdlog::info("After closing {}", filename); };
380
- auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("logs/events-sample.txt", true, handlers);
381
- spdlog::logger my_logger("some_logger", file_sink);
382
- my_logger.info("Some log line");
383
- }
384
-
385
- void replace_default_logger_example()
386
- {
387
- // store the old logger so we don't break other examples.
388
- auto old_logger = spdlog::default_logger();
389
-
390
- auto new_logger = spdlog::basic_logger_mt("new_default_logger", "logs/new-default-log.txt", true);
391
- spdlog::set_default_logger(new_logger);
392
- spdlog::set_level(spdlog::level::info);
393
- spdlog::debug("This message should not be displayed!");
394
- spdlog::set_level(spdlog::level::trace);
395
- spdlog::debug("This message should be displayed..");
396
-
397
- spdlog::set_default_logger(old_logger);
398
- }