Skip to content
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

Retain c-strings, pointers to which are used by the OS's logger subsystem #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "oslog"
description = "A minimal safe wrapper around Apple's Logging system"
repository = "https://github.com/steven-joruk/oslog"
version = "0.2.0"
version = "0.2.1"
authors = ["Steven Joruk <[email protected]>"]
edition = "2021"
license = "MIT"
Expand Down
18 changes: 16 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ impl From<log::Level> for Level {

pub struct OsLog {
inner: os_log_t,
/// These need to remain allocated or system logging code can use
/// them after they are freed.
#[allow(dead_code)]
subsystem: Option<CString>,
#[allow(dead_code)]
category: Option<CString>,
}

unsafe impl Send for OsLog {}
Expand All @@ -64,7 +70,11 @@ impl OsLog {

assert!(!inner.is_null(), "Unexpected null value from os_log_create");

Self { inner }
Self {
inner,
subsystem: Some(subsystem),
category: Some(category),
}
}

#[inline]
Expand All @@ -73,7 +83,11 @@ impl OsLog {

assert!(!inner.is_null(), "Unexpected null value for OS_DEFAULT_LOG");

Self { inner }
Self {
inner,
subsystem: None,
category: None,
}
}

#[inline]
Expand Down