Skip to content

Commit 1de9227

Browse files
committed
New Couchbase Lite C 3.2.2
1 parent aad78c9 commit 1de9227

File tree

97 files changed

+108131
-361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+108131
-361
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Cargo.lock
33

44
.vscode
5+
.idea
56

67
# MacOS directory conf
78
.DS_Store

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "couchbase_lite"
33
description = "Rust bindings for Couchbase Lite C"
44
# The first three numbers correspond to the Couchbase Lite C release, the fourth number corresponds to the Rust release
5-
version = "3.2.1-0"
5+
version = "3.2.2-0"
66

77
edition = "2024"
88

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ The different releases can be found in [this page][CBL_DOWNLOAD_PAGE].
4747
When a new C release is available, a new Rust release must be created. Running the following script will download and setup the libraries locally:
4848

4949
```shell
50-
$ ./update_cblite_c.sh -v 3.2.1
50+
$ ./update_cblite_c.sh -v 3.2.2
5151
```
5252

53-
If the script fails on MacOS, you might need to install wget or a recent bash version:
53+
If the script fails (for example `declare: -A: invalid option`, you'll need bash >= version 4) on MacOS, you might need to install wget or a recent bash version:
5454

5555
```shell
5656
$ brew install wget
@@ -119,7 +119,7 @@ $ LSAN_OPTIONS=suppressions=san.supp RUSTFLAGS="-Zsanitizer=address" cargo +nigh
119119

120120
[CBL_DOCS]: https://docs.couchbase.com/couchbase-lite/current/introduction.html
121121

122-
[CBL_API_REFERENCE]: https://docs.couchbase.com/mobile/3.2.1/couchbase-lite-c/C/html/modules.html
122+
[CBL_API_REFERENCE]: https://docs.couchbase.com/mobile/3.2.2/couchbase-lite-c/C/html/modules.html
123123

124124
[CBL_EDITIONS_DIFF]: https://www.couchbase.com/products/editions/
125125

libcblite_community/include/cbl++/CouchbaseLite.hh

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "Collection.hh"
2525
#include "Database.hh"
2626
#include "Document.hh"
27+
#include "LogSinks.hh"
2728
#include "Prediction.hh"
2829
#include "Query.hh"
2930
#include "QueryIndex.hh"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//
2+
// LogSinks.hh
3+
//
4+
// Copyright (c) 2025 Couchbase, Inc All rights reserved.
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
19+
// VOLATILE API: Couchbase Lite C++ API is not finalized, and may change in
20+
// future releases.
21+
22+
#pragma once
23+
#include "cbl/CBLLogSinks.h"
24+
25+
CBL_ASSUME_NONNULL_BEGIN
26+
27+
namespace cbl {
28+
class LogSinks {
29+
public:
30+
static void setConsole(const CBLConsoleLogSink& sink) {
31+
CBLLogSinks_SetConsole(sink);
32+
}
33+
34+
static CBLConsoleLogSink console() {
35+
return CBLLogSinks_Console();
36+
}
37+
38+
static void setCustom(const CBLCustomLogSink& sink) {
39+
CBLLogSinks_SetCustom(sink);
40+
}
41+
42+
static CBLCustomLogSink custom() {
43+
return CBLLogSinks_CustomSink();
44+
}
45+
46+
static void setFile(const CBLFileLogSink& sink) {
47+
CBLLogSinks_SetFile(sink);
48+
}
49+
50+
static CBLFileLogSink file() {
51+
return CBLLogSinks_File();
52+
}
53+
};
54+
}
55+
56+
CBL_ASSUME_NONNULL_END

libcblite_community/include/cbl/CBLDefaults.h

+15
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,21 @@ CBL_PUBLIC extern const uint32_t kCBLDefaultLogFileMaxRotateCount;
6565

6666
/** @} */
6767

68+
/** \name CBLFileLogSink
69+
@{
70+
*/
71+
72+
/** [false] Plaintext is not used, and instead binary encoding is used in log files */
73+
CBL_PUBLIC extern const bool kCBLDefaultFileLogSinkUsePlaintext;
74+
75+
/** [524288] 512 KiB for the size of a log file */
76+
CBL_PUBLIC extern const size_t kCBLDefaultFileLogSinkMaxSize;
77+
78+
/** [2] 2 files preserved during each log rotation */
79+
CBL_PUBLIC extern const uint32_t kCBLDefaultFileLogSinkMaxKeptFiles;
80+
81+
/** @} */
82+
6883
/** \name CBLFullTextIndexConfiguration
6984
@{
7085
*/

libcblite_community/include/cbl/CBLLog.h

+28-44
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,14 @@
1818

1919
#pragma once
2020
#include "CBLBase.h"
21+
#include "CBLLogSinks.h"
2122

2223
CBL_CAPI_BEGIN
2324

24-
25-
/** \defgroup logging Logging
25+
/** \defgroup logging_deprecated Logging (Deprecated)
2626
@{
27-
Managing messages that Couchbase Lite logs at runtime. */
28-
29-
/** Subsystems that log information. */
30-
typedef CBL_ENUM(uint8_t, CBLLogDomain) {
31-
kCBLLogDomainDatabase,
32-
kCBLLogDomainQuery,
33-
kCBLLogDomainReplicator,
34-
kCBLLogDomainNetwork
35-
};
36-
37-
/** Levels of log messages. Higher values are more important/severe. Each level includes the lower ones. */
38-
typedef CBL_ENUM(uint8_t, CBLLogLevel) {
39-
kCBLLogDebug, ///< Extremely detailed messages, only written by debug builds of CBL.
40-
kCBLLogVerbose, ///< Detailed messages about normally-unimportant stuff.
41-
kCBLLogInfo, ///< Messages about ordinary behavior.
42-
kCBLLogWarning, ///< Messages warning about unlikely and possibly bad stuff.
43-
kCBLLogError, ///< Messages about errors
44-
kCBLLogNone ///< Disables logging entirely.
45-
};
46-
27+
Managing messages that Couchbase Lite logs at runtime.
28+
*/
4729

4830
/** Formats and writes a message to the log, in the given domain at the given level.
4931
\warning This function takes a `printf`-style format string, with extra parameters to match the format placeholders, and has the same security vulnerabilities as other `printf`-style functions.
@@ -55,7 +37,8 @@ typedef CBL_ENUM(uint8_t, CBLLogLevel) {
5537
@param level The severity of the message. If this is lower than the current minimum level for the domain
5638
(as set by \ref CBLLog_SetConsoleLevel), nothing is logged.
5739
@param format A `printf`-style format string. `%` characters in this string introduce parameters,
58-
and corresponding arguments must follow. */
40+
and corresponding arguments must follow.
41+
@warning <b>Deprecated :</b> No alternative for this function and this function will be removed in the future release. */
5942
void CBL_Log(CBLLogDomain domain,
6043
CBLLogLevel level,
6144
const char *format, ...) CBLAPI __printflike(3, 4);
@@ -64,56 +47,55 @@ void CBL_Log(CBLLogDomain domain,
6447
@param domain The log domain to associate this message with.
6548
@param level The severity of the message. If this is lower than the current minimum level for the domain
6649
(as set by \ref CBLLog_SetConsoleLevel), nothing is logged.
67-
@param message The exact message to write to the log. */
50+
@param message The exact message to write to the log.
51+
@warning <b>Deprecated :</b> No alternative for this function and this function will be removed in the future release.*/
6852
void CBL_LogMessage(CBLLogDomain domain,
6953
CBLLogLevel level,
7054
FLSlice message) CBLAPI;
7155

72-
73-
7456
/** \name Console Logging and Custom Logging
7557
@{ */
7658

77-
/** A logging callback that the application can register.
78-
@param domain The domain of the message
79-
@param level The severity level of the message.
80-
@param message The actual formatted message. */
81-
typedef void (*CBLLogCallback)(CBLLogDomain domain,
82-
CBLLogLevel level,
83-
FLString message);
59+
/** A logging callback that the application can register. */
60+
typedef CBLLogSinkCallback CBLLogCallback;
8461

8562
/** Gets the current log level for debug console logging.
86-
Only messages at this level or higher will be logged to the console. */
63+
Only messages at this level or higher will be logged to the console.
64+
@warning <b>Deprecated :</b> Use CBLLogSinks_Console instead. */
8765
CBLLogLevel CBLLog_ConsoleLevel(void) CBLAPI;
8866

8967
/** Sets the detail level of logging.
90-
Only messages whose level is ≥ the given level will be logged to the console. */
68+
Only messages whose level is ≥ the given level will be logged to the console.
69+
@warning <b>Deprecated :</b> Use CBLLogSinks_SetConsole instead. */
9170
void CBLLog_SetConsoleLevel(CBLLogLevel) CBLAPI;
9271

9372
/** Gets the current log level for debug console logging.
94-
Only messages at this level or higher will be logged to the callback. */
73+
Only messages at this level or higher will be logged to the callback.
74+
@warning <b>Deprecated :</b> Use CBLLogSinks_CustomSink instead. */
9575
CBLLogLevel CBLLog_CallbackLevel(void) CBLAPI;
9676

9777
/** Sets the detail level of logging.
98-
Only messages whose level is ≥ the given level will be logged to the callback. */
78+
Only messages whose level is ≥ the given level will be logged to the callback.
79+
@warning <b>Deprecated :</b> Use CBLLogSinks_SetCustom instead. */
9980
void CBLLog_SetCallbackLevel(CBLLogLevel) CBLAPI;
10081

101-
/** Gets the current log callback. */
82+
/** Gets the current log callback.
83+
@warning <b>Deprecated :</b> Use CBLLogSinks_CustomSink instead. */
10284
CBLLogCallback CBLLog_Callback(void) CBLAPI;
10385

104-
/** Sets the callback for receiving log messages. If set to NULL, no messages are logged to the console. */
86+
/** Sets the callback for receiving log messages. If set to NULL, no messages are logged to the console.
87+
@warning <b>Deprecated :</b> Use CBLLogSinks_SetCustom instead. */
10588
void CBLLog_SetCallback(CBLLogCallback _cbl_nullable callback) CBLAPI;
10689

10790
/** @} */
10891

109-
110-
11192
/** \name Log File Configuration
11293
@{ */
11394

11495
/** The properties for configuring logging to files.
11596
@warning `usePlaintext` results in significantly larger log files and higher CPU usage that may slow
116-
down your app; we recommend turning it off in production. */
97+
down your app; we recommend turning it off in production.
98+
@warning <b>Deprecated :</b> Use CBLLogSinks_SetFile instead. */
11799
typedef struct {
118100
CBLLogLevel level; ///< The minimum level of message to write (Required).
119101

@@ -132,10 +114,12 @@ typedef struct {
132114
bool usePlaintext;
133115
} CBLLogFileConfiguration;
134116

135-
/** Gets the current file logging configuration, or NULL if none is configured. */
117+
/** Gets the current file logging configuration, or NULL if none is configured.
118+
@warning <b>Deprecated :</b> Use CBLLogSinks_File instead. */
136119
const CBLLogFileConfiguration* _cbl_nullable CBLLog_FileConfig(void) CBLAPI;
137120

138-
/** Sets the file logging configuration, and begins logging to files. */
121+
/** Sets the file logging configuration, and begins logging to files.
122+
@warning <b>Deprecated :</b> Use CBLLogSinks_SetFile instead. */
139123
bool CBLLog_SetFileConfig(CBLLogFileConfiguration, CBLError* _cbl_nullable outError) CBLAPI;
140124

141125
/** @} */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
//
2+
// CBLLogSink.h
3+
//
4+
// Copyright © 2024 Couchbase. All rights reserved.
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
19+
#pragma once
20+
#include "CBLBase.h"
21+
22+
CBL_CAPI_BEGIN
23+
24+
/** \defgroup logging Logging (Deprecated)
25+
@{
26+
Manages Couchbase Lite logging configuration, with three log sinks:
27+
- **Console Log Sink**: Enabled by default at the **warning** level for all domains.
28+
- **Custom Log Sink**: Logs to a user-defined callback.
29+
- **File Log Sink**: Logs to files with customizable settings.
30+
*/
31+
32+
/** The severity level of log messages */
33+
typedef CBL_ENUM(uint8_t, CBLLogLevel) {
34+
kCBLLogDebug, ///< Debug-level messages with highly detailed information, Available only in debug builds of Couchbase Lite.
35+
kCBLLogVerbose, ///< Verbose messages providing detailed operational information.
36+
kCBLLogInfo, ///< Info messages about normal application behavior.
37+
kCBLLogWarning, ///< Warning messages indicating potential issues or unusual conditions.
38+
kCBLLogError, ///< Error messages indicating a failure or problem that occurred.
39+
kCBLLogNone ///< Disables logging entirely. No messages will be logged.
40+
};
41+
42+
/** Subsystems for logging messages. */
43+
typedef CBL_ENUM(uint8_t, CBLLogDomain) {
44+
kCBLLogDomainDatabase, ///< Logging domain for the database subsystem.
45+
kCBLLogDomainQuery, ///< Logging domain for the query subsystem.
46+
kCBLLogDomainReplicator, ///< Logging domain for the replicator subsystem.
47+
kCBLLogDomainNetwork ///< Logging domain for the network subsystem.
48+
};
49+
50+
/** A bitmask representing a set of logging domains.
51+
*
52+
* Use this bitmask to specify one or more logging domains by combining the
53+
* constants with the bitwise OR operator (`|`). This is helpful for enabling
54+
* or filtering logs for specific domains. */
55+
typedef CBL_OPTIONS(uint16_t, CBLLogDomainMask) {
56+
kCBLLogDomainMaskDatabase = 1 << kCBLLogDomainDatabase,
57+
kCBLLogDomainMaskQuery = 1 << kCBLLogDomainQuery,
58+
kCBLLogDomainMaskReplicator = 1 << kCBLLogDomainReplicator,
59+
kCBLLogDomainMaskNetwork = 1 << kCBLLogDomainNetwork,
60+
kCBLLogDomainMaskAll = 0xFF
61+
};
62+
63+
/** A callback function for a custom log sink.
64+
@param domain The domain of the message
65+
@param level The severity level of the message.
66+
@param message The actual formatted message. */
67+
typedef void (*CBLLogSinkCallback)(CBLLogDomain domain, CBLLogLevel level, FLString message);
68+
69+
/** Console log sink configuration for logging to the cosole. */
70+
typedef struct {
71+
CBLLogLevel level; ///< The minimum level of message to write (Required).
72+
CBLLogDomainMask domains; ///< Bitmask for enabled log domains. Use zero for all domains.
73+
} CBLConsoleLogSink;
74+
75+
/** Custom log sink configuration for logging to a user-defined callback. */
76+
typedef struct {
77+
CBLLogLevel level; ///< The minimum level of message to write (Required).
78+
CBLLogSinkCallback _cbl_nullable callback; ///< Custom log callback (Required).
79+
CBLLogDomainMask domains; ///< Bitmask for enabled log domains. Use zero for all domains.
80+
} CBLCustomLogSink;
81+
82+
/** File log sink configuration for logging to files. */
83+
typedef struct {
84+
CBLLogLevel level; ///< The minimum level of message to write (Required).
85+
FLString directory; ///< The directory where log files will be created (Required).
86+
87+
/** The maximum number of files to save per log level.
88+
The default is \ref kCBLDefaultFileLogSinkMaxKeptFiles. */
89+
uint32_t maxKeptFiles;
90+
91+
/** The size in bytes at which a file will be rotated out (best effort).
92+
The default is \ref kCBLDefaultFileLogSinkMaxSize. */
93+
size_t maxSize;
94+
95+
/** Whether or not to log in plaintext as opposed to binary. Plaintext logging is slower and bigger.
96+
The default is \ref kCBLDefaultFileLogSinkUsePlaintext. */
97+
bool usePlaintext;
98+
} CBLFileLogSink;
99+
100+
/** Set the console log sink. To disable the console log sink, set the log level to kCBLLogNone. */
101+
void CBLLogSinks_SetConsole(CBLConsoleLogSink sink) CBLAPI;
102+
103+
/** Get the current console log sink. The console log sink is enabled at the warning level for all domains by default. */
104+
CBLConsoleLogSink CBLLogSinks_Console(void) CBLAPI;
105+
106+
/** Set the custom log sink. To disable the custom log sink, set the log level to kCBLLogNone. */
107+
void CBLLogSinks_SetCustom(CBLCustomLogSink sink) CBLAPI;
108+
109+
/** Get the current custom log sink. The custom log sink is disabled by default. */
110+
CBLCustomLogSink CBLLogSinks_CustomSink(void) CBLAPI;
111+
112+
/** Set the file log sink. To disable the file log sink, set the log level to kCBLLogNone. */
113+
void CBLLogSinks_SetFile(CBLFileLogSink sink) CBLAPI;
114+
115+
/** Get the current custom log sink. The file log sink is disabled by default. */
116+
CBLFileLogSink CBLLogSinks_File(void) CBLAPI;
117+
118+
CBL_CAPI_END
119+
120+
/** @} */

0 commit comments

Comments
 (0)