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

+1-1
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

+1-1
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

+3-3
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

+1-1
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

+29
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

+1-1
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

+29
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

+38-2
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

-29
This file was deleted.

fastimer/src/schedule/arbitrary.rs

+2-1
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

fastimer/src/schedule/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub use notify::*;
2626
mod simple;
2727
pub use simple::*;
2828

29-
use crate::debug;
29+
use crate::info;
3030
use crate::MakeDelay;
3131

3232
mod select;
@@ -86,7 +86,7 @@ where
8686
let is_shutdown = action.is_shutdown();
8787
match select(is_shutdown, delay).await {
8888
Either::Left(()) => {
89-
debug!("scheduled task {} is stopped", action.name());
89+
info!("scheduled task {} is stopped", action.name());
9090
action.teardown();
9191
true
9292
}

fastimer/src/schedule/notify.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use std::future::Future;
1616
use std::time::Duration;
1717

1818
use crate::debug;
19+
use crate::info;
1920
use crate::schedule::initial_delay_or_shutdown;
2021
use crate::schedule::BaseAction;
2122
use crate::MakeDelay;
@@ -57,7 +58,7 @@ pub trait NotifyActionExt: NotifyAction {
5758
D: MakeDelay + Send + 'static,
5859
{
5960
spawn.spawn(async move {
60-
debug!(
61+
info!(
6162
"start scheduled task {} with initial delay {:?}",
6263
self.name(),
6364
initial_delay
@@ -73,7 +74,7 @@ pub trait NotifyActionExt: NotifyAction {
7374
self.run().await;
7475

7576
if self.notified().await {
76-
debug!("scheduled task {} is stopped", self.name());
77+
info!("scheduled task {} is stopped", self.name());
7778
self.teardown();
7879
return;
7980
}

fastimer/src/schedule/simple.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::time::Instant;
1818

1919
use crate::debug;
2020
use crate::far_future;
21+
use crate::info;
2122
use crate::make_instant_from;
2223
use crate::make_instant_from_now;
2324
use crate::schedule::delay_or_shutdown;
@@ -53,7 +54,7 @@ pub trait SimpleActionExt: SimpleAction {
5354
D: MakeDelay + Send + 'static,
5455
{
5556
spawn.spawn(async move {
56-
debug!(
57+
info!(
5758
"start scheduled task {} with fixed delay {:?} and initial delay {:?}",
5859
self.name(),
5960
delay,
@@ -129,7 +130,7 @@ pub trait SimpleActionExt: SimpleAction {
129130
}
130131

131132
spawn.spawn(async move {
132-
debug!(
133+
info!(
133134
"start scheduled task {} at fixed rate {:?} with initial delay {:?}",
134135
self.name(),
135136
period,

0 commit comments

Comments
 (0)