Skip to content

Commit 5474dd5

Browse files
authored
Merge pull request #83 from elast0ny/fix/logging
Fix logging feature issues
2 parents 2b2d98d + 0e44a29 commit 5474dd5

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "shared_memory"
33
description = "A user friendly crate that allows you to share memory between processes"
4-
version = "0.12.2"
4+
version = "0.12.3"
55
authors = ["ElasT0ny <elast0ny00@gmail.com>"]
66
license = "MIT OR Apache-2.0"
77
edition = "2018"
@@ -22,7 +22,8 @@ categories = [
2222
exclude = ["ci/*", ".github/*"]
2323

2424
[features]
25-
default = ["log/release_max_level_off"]
25+
default = []
26+
logging = ["log"]
2627

2728
[dependencies]
2829
cfg-if = "1.0"

src/lib.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,21 @@ use std::fs::remove_file;
99
use std::path::{Path, PathBuf};
1010

1111
use cfg_if::cfg_if;
12-
use log::*;
12+
13+
#[cfg(feature = "logging")]
14+
pub use log;
15+
#[cfg(not(feature = "logging"))]
16+
#[allow(unused_macros)]
17+
mod log {
18+
macro_rules! trace (($($tt:tt)*) => {{}});
19+
macro_rules! debug (($($tt:tt)*) => {{}});
20+
macro_rules! info (($($tt:tt)*) => {{}});
21+
macro_rules! warn (($($tt:tt)*) => {{}});
22+
macro_rules! error (($($tt:tt)*) => {{}});
23+
pub(crate) use {debug, trace};
24+
}
25+
26+
use crate::log::*;
1327

1428
mod error;
1529
pub use error::*;
@@ -27,7 +41,7 @@ cfg_if! {
2741
}
2842
}
2943

30-
#[derive(Clone)]
44+
#[derive(Clone, Default)]
3145
/// Struct used to configure different parameters before creating a shared memory mapping
3246
pub struct ShmemConf {
3347
owner: bool,
@@ -47,17 +61,7 @@ impl Drop for ShmemConf {
4761
}
4862
}
4963
}
50-
impl Default for ShmemConf {
51-
fn default() -> Self {
52-
Self {
53-
owner: false,
54-
os_id: None,
55-
overwrite_flink: false,
56-
flink_path: None,
57-
size: 0,
58-
}
59-
}
60-
}
64+
6165
impl ShmemConf {
6266
/// Create a new default shmem config
6367
pub fn new() -> Self {

src/unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::os::unix::io::RawFd;
22
use std::ptr::null_mut;
33

4-
use log::*;
4+
use crate::log::*;
55
use nix::fcntl::OFlag;
66
use nix::sys::mman::{mmap, munmap, shm_open, shm_unlink, MapFlags, ProtFlags};
77
use nix::sys::stat::{fstat, Mode};

src/windows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::os::windows::{fs::OpenOptionsExt, io::AsRawHandle};
44
use std::path::PathBuf;
55
use std::ptr::null_mut;
66

7-
use log::*;
7+
use crate::log::*;
88
use win_sys::*;
99

1010
use crate::ShmemError;

0 commit comments

Comments
 (0)