Skip to content

Commit

Permalink
Use oslogger for macOS logging (#891)
Browse files Browse the repository at this point in the history
## 🎟️ Tracking

<!-- Paste the link to the Jira or GitHub issue or otherwise describe /
point to where this change is coming from. -->

## 📔 Objective

Xcode doesn't seem to be able to pick up `stdio` logs from secondary
processes like autofill extensions. This PR switches to using native iOS
logging which Xcode supports.

## 📸 Screenshots


![image](https://github.com/bitwarden/sdk/assets/2285588/72ffb8d5-1597-4cdf-98f0-33f0becbbcc7)

## ⏰ Reminders before review

- Contributor guidelines followed
- All formatters and local linters executed and passed
- Written new unit and / or integration tests where applicable
- Protected functional changes with optionality (feature flags)
- Used internationalization (i18n) for all UI strings
- CI builds passed
- Communicated to DevOps any deployment requirements
- Updated any necessary documentation (Confluence, contributing docs) or
informed the documentation
  team

## 🦮 Reviewer guidelines

<!-- Suggested interactions but feel free to use (or not) as you desire!
-->

- 👍 (`:+1:`) or similar for great changes
- 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info
- ❓ (`:question:`) for questions
- 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry
that's not quite a confirmed
  issue and could potentially benefit from discussion
- 🎨 (`:art:`) for suggestions / improvements
- ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or
concerns needing attention
- 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or
indications of technical debt
- ⛏ (`:pick:`) for minor or nitpick changes
  • Loading branch information
coroiu authored Jul 9, 2024
1 parent a8a96c4 commit 6decd1f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 21 deletions.
65 changes: 45 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/bitwarden-uniffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ uuid = ">=1.3.3, <2"
[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.14"

[target.'cfg(target_os = "ios")'.dependencies]
oslog = "0.2.0"

[build-dependencies]
uniffi = { version = "=0.27.2", features = ["build"] }

Expand Down
7 changes: 6 additions & 1 deletion crates/bitwarden-uniffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@ impl Client {
}

fn init_logger() {
#[cfg(not(target_os = "android"))]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info"))
.try_init();

#[cfg(target_os = "ios")]
let _ = oslog::OsLogger::new("com.8bit.bitwarden")
.level_filter(log::LevelFilter::Info)
.init();

#[cfg(target_os = "android")]
android_logger::init_once(
android_logger::Config::default().with_max_level(uniffi::deps::log::LevelFilter::Info),
Expand Down

0 comments on commit 6decd1f

Please sign in to comment.