Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(iroh): Rename target for events #2977

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion iroh-relay/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ impl Actor {
}

event!(
target: "events.net.relay.connected",
target: "iroh::events::relay::connected",
Level::DEBUG,
home = self.is_preferred,
url = %self.url,
Expand Down
15 changes: 8 additions & 7 deletions iroh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ The library uses [tracing](https://docs.rs/tracing) to for logging as
well as for **structured events**. Events are different from normal
logging by convention:

- The [target] has a prefix of `events` and target names are dot-separated.
- The [target] has a prefix of `$crate_name::events` and target names
are `::` separated.

For this library the target will always start with `events.net.`.
For this library the target will always start with `iroh::events::`.

- There is **no message**.

Expand All @@ -38,12 +39,12 @@ logging by convention:

### Using events

If desired an application can use the `events.*` target to handle
events by a different subscriber. However with the default file
logging it is already easy to search for all events, e.g. using
If desired an application can use the `$crate_name::events` target to
handle events by a different subscriber. However with the default
file logging it is already easy to search for all events, e.g. using
ripgrep:

`rg 'events\.[a-z_\-.]+' path/to/iroh/logs/iroh.YYYY-MM-DD-NN.log`
`rg 'events::[a-z_\-:]+' path/to/iroh/logs/iroh.YYYY-MM-DD-NN.log`

Which will also highlight the full target name by default on a colour
supporting terminal.
Expand All @@ -60,7 +61,7 @@ recommended to write them using the `event!()` macro:

```rust
event!(
target: "event.net.subject",
target: "iroh::event::subject",
Level::DEBUG,
field = value,
);
Expand Down
8 changes: 4 additions & 4 deletions iroh/src/magicsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ impl MagicSock {
match src {
DiscoMessageSource::Relay { url, .. } => {
event!(
target: "events.net.call-me-maybe.recv",
target: "iroh::events::call-me-maybe::recv",
Level::DEBUG,
remote_node = sender.fmt_short(),
via = ?url,
Expand Down Expand Up @@ -934,7 +934,7 @@ impl MagicSock {
ping_observed_addr: addr.clone(),
});
event!(
target: "events.net.pong.sent",
target: "iroh::events::pong::sent",
Level::DEBUG,
remote_node = %sender.fmt_short(),
dst = ?addr,
Expand Down Expand Up @@ -1060,7 +1060,7 @@ impl MagicSock {
Ok(()) => {
if let disco::Message::CallMeMaybe(CallMeMaybe { ref my_numbers }) = msg {
event!(
target: "events.net.call-me-maybe.sent",
target: "iroh::events::call-me-maybe::sent",
Level::DEBUG,
remote_node = %dst.fmt_short(),
via = ?url,
Expand Down Expand Up @@ -2465,7 +2465,7 @@ impl DiscoveredDirectAddrs {
let updated = self.addrs.update(addrs).is_ok();
if updated {
event!(
target: "events.net.direct_addrs",
target: "iroh::events::direct_addrs",
Level::DEBUG,
addrs = ?self.addrs.get(),
);
Expand Down
8 changes: 4 additions & 4 deletions iroh/src/magicsock/node_map/node_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl NodeState {
if let Ok(prev_typ) = self.conn_type.update(typ.clone()) {
// The connection type has changed.
event!(
target: "events.net.conn_type.changed",
target: "iroh::events::conn_type::changed",
Level::DEBUG,
remote_node = %self.node_id.fmt_short(),
conn_type = ?typ,
Expand Down Expand Up @@ -470,7 +470,7 @@ impl NodeState {
trace!(tx = %hex::encode(tx_id), %dst, ?purpose,
dst = %self.node_id.fmt_short(), "start ping");
event!(
target: "events.net.ping.sent",
target: "iroh::events::ping::sent",
Level::DEBUG,
remote_node = %self.node_id.fmt_short(),
?dst,
Expand Down Expand Up @@ -761,7 +761,7 @@ impl NodeState {
}
};
event!(
target: "events.net.ping.recv",
target: "iroh::events::ping::recv",
Level::DEBUG,
remote_node = %self.node_id.fmt_short(),
src = ?path,
Expand Down Expand Up @@ -863,7 +863,7 @@ impl NodeState {
src: SendAddr,
) -> Option<(SocketAddr, PublicKey)> {
event!(
target: "events.net.pong.recv",
target: "iroh::events::pong::recv",
Level::DEBUG,
remote_node = self.node_id.fmt_short(),
?src,
Expand Down
4 changes: 2 additions & 2 deletions iroh/src/magicsock/node_map/path_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl PathState {
if let SendAddr::Udp(ref path) = self.path {
if self.recent_pong.is_none() {
event!(
target: "events.net.holepunched",
target: "iroh::events::holepunched",
Level::DEBUG,
remote_node = %self.node_id.fmt_short(),
path = ?path,
Expand Down Expand Up @@ -259,7 +259,7 @@ impl PathState {
None => {
if let SendAddr::Udp(ref addr) = self.path {
event!(
target: "events.net.holepunched",
target: "iroh::events::holepunched",
Level::DEBUG,
remote_node = %self.node_id.fmt_short(),
path = ?addr,
Expand Down
Loading