Skip to content

Commit 7ed15d7

Browse files
bors[bot]yoshuawuyts
andauthoredSep 16, 2019
Merge #199
199: remove custom log code in favor of macro crate r=stjepang a=yoshuawuyts This removes our custom log macro code in favor of using [`kv-log-macro`](https://github.com/yoshuawuyts/kv-log-macro). This is a temporary crate that exists only until rust-lang/log#353 lands which enables progress on rust-lang/log#328. Thanks! Co-authored-by: Yoshua Wuyts <[email protected]>
2 parents be123b2 + 9c82d5e commit 7ed15d7

File tree

5 files changed

+24
-63
lines changed

5 files changed

+24
-63
lines changed
 

‎Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ mio-uds = "0.6.7"
3838
num_cpus = "1.10.1"
3939
pin-utils = "0.1.0-alpha.4"
4040
slab = "0.4.2"
41+
kv-log-macro = "1.0.4"
4142

4243
[dev-dependencies]
4344
femme = "1.2.0"

‎src/task/block_on.rs

+12-15
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ use std::sync::Arc;
66
use std::task::{RawWaker, RawWakerVTable};
77
use std::thread::{self, Thread};
88

9-
use super::log_utils;
109
use super::pool;
1110
use super::task;
1211
use crate::future::Future;
1312
use crate::task::{Context, Poll, Waker};
1413
use crate::utils::abort_on_panic;
1514

15+
use kv_log_macro::trace;
16+
1617
/// Spawns a task and blocks the current thread on its result.
1718
///
1819
/// Calling this function is similar to [spawning] a thread and immediately [joining] it, except an
@@ -58,13 +59,11 @@ where
5859
// Log this `block_on` operation.
5960
let child_id = tag.task_id().as_u64();
6061
let parent_id = pool::get_task(|t| t.id().as_u64()).unwrap_or(0);
61-
log_utils::print(
62-
format_args!("block_on"),
63-
log_utils::LogData {
64-
parent_id,
65-
child_id,
66-
},
67-
);
62+
63+
trace!("block_on", {
64+
parent_id: parent_id,
65+
child_id: child_id,
66+
});
6867

6968
// Wrap the future into one that drops task-local variables on exit.
7069
let future = async move {
@@ -73,13 +72,11 @@ where
7372
// Abort on panic because thread-local variables behave the same way.
7473
abort_on_panic(|| pool::get_task(|task| task.metadata().local_map.clear()));
7574

76-
log_utils::print(
77-
format_args!("block_on completed"),
78-
log_utils::LogData {
79-
parent_id,
80-
child_id,
81-
},
82-
);
75+
trace!("block_on completed", {
76+
parent_id: parent_id,
77+
child_id: child_id,
78+
});
79+
8380
res
8481
};
8582

‎src/task/log_utils.rs

-32
This file was deleted.

‎src/task/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pub use task::{JoinHandle, Task, TaskId};
3232

3333
mod block_on;
3434
mod local;
35-
mod log_utils;
3635
mod pool;
3736
mod sleep;
3837
mod task;

‎src/task/pool.rs

+11-15
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::thread;
44

55
use crossbeam_channel::{unbounded, Sender};
66
use lazy_static::lazy_static;
7+
use kv_log_macro::trace;
78

8-
use super::log_utils;
99
use super::task;
1010
use super::{JoinHandle, Task};
1111
use crate::future::Future;
@@ -130,13 +130,11 @@ where
130130
// Log this `spawn` operation.
131131
let child_id = tag.task_id().as_u64();
132132
let parent_id = get_task(|t| t.id().as_u64()).unwrap_or(0);
133-
log_utils::print(
134-
format_args!("spawn"),
135-
log_utils::LogData {
136-
parent_id,
137-
child_id,
138-
},
139-
);
133+
134+
trace!("spawn", {
135+
parent_id: parent_id,
136+
child_id: child_id,
137+
});
140138

141139
// Wrap the future into one that drops task-local variables on exit.
142140
let future = async move {
@@ -145,13 +143,11 @@ where
145143
// Abort on panic because thread-local variables behave the same way.
146144
abort_on_panic(|| get_task(|task| task.metadata().local_map.clear()));
147145

148-
log_utils::print(
149-
format_args!("spawn completed"),
150-
log_utils::LogData {
151-
parent_id,
152-
child_id,
153-
},
154-
);
146+
trace!("spawn completed", {
147+
parent_id: parent_id,
148+
child_id: child_id,
149+
});
150+
155151
res
156152
};
157153

0 commit comments

Comments
 (0)