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

remove global panic hook #91

Merged
merged 1 commit into from
Aug 6, 2023
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Change
- **Break** change the `request_log_files_for_date` function paramter to a time range https://github.com/s1rius/ezlog/pull/90
- **Break** android:rename native function name, remove underline https://github.com/s1rius/ezlog/pull/26
- remove global panic hook https://github.com/s1rius/ezlog/pull/91
- Use varint to describe log's content length https://github.com/s1rius/ezlog/pull/32
- Compress first then encrypt https://github.com/s1rius/ezlog/pull/40

Expand Down
2 changes: 0 additions & 2 deletions ezlog-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ crate-type = ["lib", "cdylib", "staticlib"]

[features]
default = []
backtrace = ["dep:backtrace"]
log = ["dep:log"]
decode = ["dep:aes-gcm"]
android_logger = ["log","dep:android_logger"]
Expand All @@ -33,7 +32,6 @@ crossbeam-channel = "0.5"
thread-id = "4.0.0"
once_cell = "1.12"
thiserror = "1"
backtrace = { version = "0.3", optional = true }
integer-encoding = "3.0"
bitflags = "2.0.1"
android_logger = { version = "0.13", optional = true }
Expand Down
1 change: 0 additions & 1 deletion ezlog-core/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ pub enum Event {
TrimEnd,
FFiError,
ChannelError,
Panic,
}

/// Every important log case make an event.
Expand Down
3 changes: 1 addition & 2 deletions ezlog-core/src/init.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{ptr, sync::Arc};

use crate::{
hook_panic, EZLogCallback, EZMsg, EZRecord, EventListener, EventPrinter, Formatter, LogService,
EZLogCallback, EZMsg, EZRecord, EventListener, EventPrinter, Formatter, LogService,
};

/// InitBuilder is used to init ezlog
Expand Down Expand Up @@ -199,7 +199,6 @@ impl InitBuilder {
/// real init ezlog
pub fn init(self) -> EZLog {
crate::LOG_SERVICE_INIT.call_once(|| unsafe {
hook_panic();
#[cfg(all(target_os = "android", feature = "android_logger"))]
if self.debug {
android_logger::init_once(
Expand Down
18 changes: 0 additions & 18 deletions ezlog-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ use std::{
thread,
};

#[cfg(feature = "backtrace")]
use backtrace::Backtrace;

/// A [EZLogger] default name. current is "default".
pub const DEFAULT_LOG_NAME: &str = "default";
pub(crate) const FILE_SIGNATURE: &[u8; 2] = b"ez";
Expand Down Expand Up @@ -893,21 +890,6 @@ impl From<CompressLevel> for u8 {
}
}

#[cfg(feature = "backtrace")]
fn hook_panic() {
std::panic::set_hook(Box::new(|p| {
let bt = Backtrace::new();
event!(Event::Panic, &format!("ezlog: \n {p:?} \n{bt:?} \n"));
}));
}

#[cfg(not(feature = "backtrace"))]
fn hook_panic() {
std::panic::set_hook(Box::new(|p| {
event!(Event::Panic, &format!("ezlog: \n {p:?}"));
}));
}

#[cfg(test)]
mod tests {
use crate::recorder::EZRecordBuilder;
Expand Down