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

Remove log macros and fix log node prefix #127

Merged
merged 2 commits into from
Jul 9, 2024

Conversation

chenyukang
Copy link
Collaborator

@chenyukang chenyukang commented Jul 8, 2024

There are two drawbacks for #120

  1. we're losing source file and line number in log event
  2. we macros don't support all argument format: https://docs.rs/tracing/latest/tracing/macro.info.html

There are several methods to propagate the span to spawned tasks:

  1. instrument when using tokio spawn or actor span:
Actor::spawn_linked(...).instrument(span).await;
  1. instrument with macors for a function
#[tracing::instrument(name = "Actor", skip(self, myself, args), fields(id = crate::get_node_prefix()))]
async fn pre_start(
        &self,
        myself: ActorRef<Self::Msg>,
        args: Self::Arguments,
    ) -> Result<Self::State, ActorProcessingErr> {
...
}

This PR use a trivial hack to achieve it, I think it's more general since developers may forget to set instrument for actors.

@chenyukang chenyukang force-pushed the yukang-fix-log-file-and-lineno branch from 6501e8b to ec761fa Compare July 8, 2024 10:35
@chenyukang chenyukang force-pushed the yukang-fix-log-file-and-lineno branch from ec761fa to d3355b5 Compare July 8, 2024 10:36
@quake quake merged commit 3cdb357 into nervosnetwork:main Jul 9, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants