Skip to content

Commit

Permalink
Merge pull request #46 from baoyachi/issue/checko_--no-default-features
Browse files Browse the repository at this point in the history
Fix build failure when using target features
  • Loading branch information
baoyachi authored Sep 23, 2024
2 parents 4f4a950 + 9968d2c commit e86fbb6
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
# it's an unstable feature.
rust-version: nightly
- uses: actions/checkout@v4
- run: cargo +nightly fmt -- --check --config-path <(echo 'license_template_path = "HEADER"')
- run: cargo +nightly fmt -- --check

lint:
runs-on: ubuntu-latest
Expand All @@ -33,7 +33,9 @@ jobs:
- name: Set up Rust
uses: hecrj/setup-rust-action@v2
- uses: actions/checkout@master
- run: cargo check --all-targets --all-features
- run: |
cargo check --all-targets --all-features
cargo check --no-default-features
test:
strategy:
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "2.0.0"
version = "2.1.0"
edition = "2021"
authors = ["baoyachi <liaoymxsdl@gmail.com>"]
description = "A simple log. It's really simple use"
Expand All @@ -26,10 +26,10 @@ license.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
log = "0.4.11"
log = { version = "0.4.11", features = ["serde", "std"] }
log4rs = { version = "1.1.1", default-features = false, features = ["all_components", "humantime", "serde", "serde-value", "yaml_format", "gzip"], optional = true }
once_cell = { version = "1.15.0", default-features = false, optional = true }
serde = { version = "1.0.145", default-features = false, features = ["derive"] }
serde = { version = "1.0.145", features = ["derive"] }
winnow = "0.6.18"

[dependencies.simple-log-derive]
Expand Down
22 changes: 2 additions & 20 deletions src/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

use crate::level::{parse_level, LevelInto};
use crate::out_kind::OutKind;
use crate::SimpleResult;
use crate::{InnerLevel, SimpleResult};
use log::LevelFilter;
use log4rs::append::console::ConsoleAppender;
use log4rs::append::rolling_file::policy::compound::roll::fixed_window::FixedWindowRoller;
Expand Down Expand Up @@ -241,10 +241,10 @@ pub fn get_log_conf() -> SimpleResult<LogConfig> {
let config = log_conf.lock().unwrap().log_config.clone();
Ok(config)
}

use crate::level::deserialize_level;
use crate::out_kind::deserialize_out_kind;

pub(crate) type InnerLevel = (LevelFilter, Vec<TargetLevel>);
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct LogConfig {
Expand Down Expand Up @@ -278,24 +278,6 @@ impl Default for LogConfig {
}
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct TargetLevel {
name: String,
level: LevelFilter,
}

impl<S> From<(S, LevelFilter)> for TargetLevel
where
S: AsRef<str>,
{
fn from(value: (S, LevelFilter)) -> Self {
Self {
name: value.0.as_ref().to_string(),
level: value.1,
}
}
}

impl LogConfig {
fn default_basename(&self) -> String {
let arg0 = std::env::args()
Expand Down
5 changes: 2 additions & 3 deletions src/level.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use crate::inner::InnerLevel;
use crate::InnerLevel;
use core::fmt;
use log::{Level, LevelFilter};
pub use parser::*;
use serde::de::DeserializeSeed;
use serde::{de, Deserializer};

pub(crate) mod parser {
use crate::inner::InnerLevel;
use crate::TargetLevel;
use crate::{InnerLevel, TargetLevel};
use log::LevelFilter;
use std::str::FromStr;
use winnow::ascii::{alpha1, multispace0};
Expand Down
21 changes: 21 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,28 @@ pub use inner::*;

pub use log::Level;
pub use log::LevelFilter;
use serde::{Deserialize, Serialize};

#[cfg(feature = "target")]
pub use simple_log_derive::*;

pub type SimpleResult<T> = Result<T, String>;
pub(crate) type InnerLevel = (LevelFilter, Vec<TargetLevel>);

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct TargetLevel {
name: String,
level: LevelFilter,
}

impl<S> From<(S, LevelFilter)> for TargetLevel
where
S: AsRef<str>,
{
fn from(value: (S, LevelFilter)) -> Self {
Self {
name: value.0.as_ref().to_string(),
level: value.1,
}
}
}
2 changes: 1 addition & 1 deletion src/out_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<'de> de::Visitor<'de> for KindSerde {
}
}

pub fn deserialize_out_kind<'de, D>(deserializer: D) -> Result<Vec<OutKind>, D::Error>
pub(crate) fn deserialize_out_kind<'de, D>(deserializer: D) -> Result<Vec<OutKind>, D::Error>

Check warning on line 77 in src/out_kind.rs

View workflow job for this annotation

GitHub Actions / compile

function `deserialize_out_kind` is never used

Check warning on line 77 in src/out_kind.rs

View workflow job for this annotation

GitHub Actions / compile

function `deserialize_out_kind` is never used
where
D: Deserializer<'de>,
{
Expand Down

0 comments on commit e86fbb6

Please sign in to comment.