Skip to content

cblite 3.2.2 update: New logging API #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 17, 2025
Merged

Conversation

Nao-ris
Copy link
Contributor

@Nao-ris Nao-ris commented Apr 15, 2025

New Logging API

Couchbase Lite 3.2.2 introduces a new Logging API. The new Logging API has the following benefits:

  • Log sinks are now thread safe, removing risk of inconsistent states during initialization.
  • Simplified API and reduced implementation complexity.

@corentinmb corentinmb changed the title New logging API cblite 3.2.2 update: New logging API Apr 17, 2025
@Nao-ris Nao-ris marked this pull request as ready for review April 17, 2025 12:54
@Nao-ris Nao-ris requested a review from a team as a code owner April 17, 2025 12:54
@@ -11,6 +11,7 @@ keywords = ["couchbase"]
categories = ["database"]

[dependencies]
bitflags = "2.9.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR review help: New dependency to implement bit masks (we need to map to a CBlite C structure that create bit mask to concatenate domains to log, see

/** A bitmask representing a set of logging domains.
*
* Use this bitmask to specify one or more logging domains by combining the
* constants with the bitwise OR operator (`|`). This is helpful for enabling
* or filtering logs for specific domains. */
typedef CBL_OPTIONS(uint16_t, CBLLogDomainMask) {
kCBLLogDomainMaskDatabase = 1 << kCBLLogDomainDatabase,
kCBLLogDomainMaskQuery = 1 << kCBLLogDomainQuery,
kCBLLogDomainMaskReplicator = 1 << kCBLLogDomainReplicator,
kCBLLogDomainMaskNetwork = 1 << kCBLLogDomainNetwork,
kCBLLogDomainMaskAll = 0xFF
};

log_sink.level = kCBLLogDebug;
log_sink.domains = kCBLLogDomainMaskAll;

CBLLogSinks_SetConsole(log_sink);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR review help: Just for testing...

level: log_sink.level as u8,
callback: Some(invoke_log_callback),
domains: log_sink.domains.bits() as u16,
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR review help: implementation of CBLite C lib (thanks to bindings), more info in

fn generate_bindings() -> Result<(), Box<dyn Error>> {

$crate::logging::Domain::Database, $crate::logging::Level::Debug,
format_args!($($arg)*)));
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR review help: Removed because useless

@Nao-ris Nao-ris merged commit e4353e8 into main Apr 17, 2025
5 checks passed
@Nao-ris Nao-ris deleted the BC-309_logging_new_api branch April 17, 2025 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants