Skip to content

Commit 513ea29

Browse files
authored
refactor: improve logs (#26)
Signed-off-by: tison <[email protected]>
1 parent ac89745 commit 513ea29

File tree

13 files changed

+113
-45
lines changed

13 files changed

+113
-45
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
strategy:
5454
matrix:
5555
os: [ ubuntu-22.04, macos-14, windows-2022 ]
56-
rust-version: [ "1.83.0", "stable" ]
56+
rust-version: [ "1.85.0", "stable" ]
5757
runs-on: ${{ matrix.os }}
5858
steps:
5959
- uses: actions/checkout@v4

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ homepage = "https://github.com/fast/fastimer"
2222
license = "Apache-2.0"
2323
readme = "README.md"
2424
repository = "https://github.com/fast/fastimer"
25-
rust-version = "1.83.0"
25+
rust-version = "1.85.0"
2626
version = "0.7.0"
2727

2828
[workspace.dependencies]

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
[![Crates.io][crates-badge]][crates-url]
44
[![Documentation][docs-badge]][docs-url]
5-
[![MSRV 1.83][msrv-badge]](https://www.whatrustisit.com)
5+
[![MSRV 1.85][msrv-badge]](https://www.whatrustisit.com)
66
[![Apache 2.0 licensed][license-badge]][license-url]
77
[![Build Status][actions-badge]][actions-url]
88

99
[crates-badge]: https://img.shields.io/crates/v/fastimer.svg
1010
[crates-url]: https://crates.io/crates/fastimer
1111
[docs-badge]: https://docs.rs/fastimer/badge.svg
12-
[msrv-badge]: https://img.shields.io/badge/MSRV-1.83-green?logo=rust
12+
[msrv-badge]: https://img.shields.io/badge/MSRV-1.85-green?logo=rust
1313
[docs-url]: https://docs.rs/fastimer
1414
[license-badge]: https://img.shields.io/crates/l/fastimer
1515
[license-url]: LICENSE
@@ -50,7 +50,7 @@ Read the online documents at https://docs.rs/fastimer.
5050

5151
## Minimum Supported Rust Version (MSRV)
5252

53-
This crate is built against the latest stable release, and its minimum supported rustc version is 1.80.0.
53+
This crate is built against the latest stable release, and its minimum supported rustc version is 1.85.0.
5454

5555
The policy is that the minimum Rust version required to use this crate can be increased in minor version updates. For example, if Fastimer 1.0 requires Rust 1.20.0, then Fastimer 1.0.z for all values of z will also require Rust 1.20.0 or newer. However, Fastimer 1.y for y > 0 may require a newer minimum version of Rust.
5656

fastimer-driver/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
name = "fastimer-driver"
1717

1818
description = "This crate implements a timer driver that can work with any async runtime scheduler."
19+
readme = "README.md"
1920

2021
edition.workspace = true
2122
homepage.workspace = true
2223
license.workspace = true
23-
readme.workspace = true
2424
repository.workspace = true
2525
rust-version.workspace = true
2626
version.workspace = true

fastimer-driver/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Fastimer Driver
2+
3+
[![Crates.io][crates-badge]][crates-url]
4+
[![Documentation][docs-badge]][docs-url]
5+
[![MSRV 1.85][msrv-badge]](https://www.whatrustisit.com)
6+
7+
[crates-badge]: https://img.shields.io/crates/v/fastimer-driver.svg
8+
[crates-url]: https://crates.io/crates/fastimer-driver
9+
[docs-badge]: https://docs.rs/fastimer-driver/badge.svg
10+
[msrv-badge]: https://img.shields.io/badge/MSRV-1.85-green?logo=rust
11+
[docs-url]: https://docs.rs/fastimer-driver
12+
13+
## Overview
14+
15+
This crate implements a timer driver that can work with any async runtime scheduler.
16+
17+
## Documentation
18+
19+
Read the online documents at https://docs.rs/fastimer-driver.
20+
21+
## Minimum Supported Rust Version (MSRV)
22+
23+
This crate is built against the latest stable release, and its minimum supported rustc version is 1.85.0.
24+
25+
The policy is that the minimum Rust version required to use this crate can be increased in minor version updates. For example, if Fastimer 1.0 requires Rust 1.20.0, then Fastimer 1.0.z for all values of z will also require Rust 1.20.0 or newer. However, Fastimer 1.y for y > 0 may require a newer minimum version of Rust.
26+
27+
## License
28+
29+
This project is licensed under [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).

fastimer-tokio/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
name = "fastimer-tokio"
1717

1818
description = "This crates provides tokio runtime integration for fastimer."
19+
readme = "README.md"
1920

2021
edition.workspace = true
2122
homepage.workspace = true
2223
license.workspace = true
23-
readme.workspace = true
2424
repository.workspace = true
2525
rust-version.workspace = true
2626
version.workspace = true

fastimer-tokio/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Fastimer Tokio
2+
3+
[![Crates.io][crates-badge]][crates-url]
4+
[![Documentation][docs-badge]][docs-url]
5+
[![MSRV 1.85][msrv-badge]](https://www.whatrustisit.com)
6+
7+
[crates-badge]: https://img.shields.io/crates/v/fastimer-tokio.svg
8+
[crates-url]: https://crates.io/crates/fastimer-tokio
9+
[docs-badge]: https://docs.rs/fastimer-tokio/badge.svg
10+
[msrv-badge]: https://img.shields.io/badge/MSRV-1.85-green?logo=rust
11+
[docs-url]: https://docs.rs/fastimer-tokio
12+
13+
## Overview
14+
15+
This crates provides tokio runtime integration for fastimer.
16+
17+
## Documentation
18+
19+
Read the online documents at https://docs.rs/fastimer-tokio.
20+
21+
## Minimum Supported Rust Version (MSRV)
22+
23+
This crate is built against the latest stable release, and its minimum supported rustc version is 1.85.0.
24+
25+
The policy is that the minimum Rust version required to use this crate can be increased in minor version updates. For example, if Fastimer 1.0 requires Rust 1.20.0, then Fastimer 1.0.z for all values of z will also require Rust 1.20.0 or newer. However, Fastimer 1.y for y > 0 may require a newer minimum version of Rust.
26+
27+
## License
28+
29+
This project is licensed under [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).

fastimer/src/lib.rs

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ use std::future::Future;
4343
use std::time::Duration;
4444
use std::time::Instant;
4545

46-
mod macros;
47-
4846
mod interval;
4947
pub use interval::*;
5048

@@ -73,6 +71,8 @@ pub fn make_instant_from_now(dur: Duration) -> Instant {
7371
}
7472

7573
/// A trait for creating delay futures.
74+
///
75+
/// See [`MakeDelayExt`] for extension methods.
7676
pub trait MakeDelay {
7777
/// The future returned by the `delay`/`delay_until` method.
7878
type Delay: Future<Output = ()> + Send;
@@ -126,3 +126,39 @@ pub trait MakeDelayExt: MakeDelay {
126126
}
127127

128128
impl<T: MakeDelay> MakeDelayExt for T {}
129+
130+
pub(crate) use self::macros::debug;
131+
pub(crate) use self::macros::info;
132+
133+
#[cfg(feature = "logging")]
134+
mod macros {
135+
macro_rules! debug {
136+
(target: $target:expr, $($arg:tt)+) => (log::debug!(target: $target, $($arg)+));
137+
($($arg:tt)+) => (log::debug!($($arg)+));
138+
}
139+
140+
macro_rules! info {
141+
(target: $target:expr, $($arg:tt)+) => (log::info!(target: $target, $($arg)+));
142+
($($arg:tt)+) => (log::info!($($arg)+));
143+
}
144+
145+
pub(crate) use debug;
146+
pub(crate) use info;
147+
}
148+
149+
#[cfg(not(feature = "logging"))]
150+
#[macro_use]
151+
mod macros {
152+
macro_rules! info {
153+
(target: $target:expr, $($arg:tt)+) => {};
154+
($($arg:tt)+) => {};
155+
}
156+
157+
macro_rules! debug {
158+
(target: $target:expr, $($arg:tt)+) => {};
159+
($($arg:tt)+) => {};
160+
}
161+
162+
pub(crate) use debug;
163+
pub(crate) use info;
164+
}

fastimer/src/macros.rs

Lines changed: 0 additions & 29 deletions
This file was deleted.

fastimer/src/schedule/arbitrary.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::time::Duration;
1717
use std::time::Instant;
1818

1919
use crate::debug;
20+
use crate::info;
2021
use crate::schedule::delay_or_shutdown;
2122
use crate::schedule::initial_delay_or_shutdown;
2223
use crate::schedule::BaseAction;
@@ -48,7 +49,7 @@ pub trait ArbitraryDelayActionExt: ArbitraryDelayAction {
4849
D: MakeDelay + Send + 'static,
4950
{
5051
spawn.spawn(async move {
51-
debug!(
52+
info!(
5253
"start scheduled task {} with initial delay {:?}",
5354
self.name(),
5455
initial_delay

0 commit comments

Comments
 (0)