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

Research logging libraries, choose one and deploy it in tofn and tofnd #19

Closed
sdaveas opened this issue Mar 19, 2021 · 6 comments · Fixed by #31
Closed

Research logging libraries, choose one and deploy it in tofn and tofnd #19

sdaveas opened this issue Mar 19, 2021 · 6 comments · Fixed by #31
Assignees
Milestone

Comments

@sdaveas
Copy link
Contributor

sdaveas commented Mar 19, 2021

No description provided.

@sdaveas sdaveas self-assigned this Mar 19, 2021
@ggutoski
Copy link
Contributor

ggutoski commented Apr 6, 2021

Configurability:

  • "context", which is basically a prefix string. eg. "tofn party X, round Y, event description". The "tofn", "party X", "round Y" parts should be part of the context prefix, so I need only say log("event description)
  • Need the ability to direct logging output. eg. ignore, file, stdout, etc
  • tofnd is the end product: it configures the logger and passes it to tofn. tofn is the library: it must use the logger received from the consumer of the library (eg. tofnd) in whatever configuration is specified by that consumer.

@sdaveas
Copy link
Contributor Author

sdaveas commented Apr 7, 2021

log is the most popular library for logs and is actively maintained the rust team. We should definitely use that.

log is a framework and isn't very useful by itself, though. It has to be combined with a logger to print outputs. simplelog is quite popular and active, and seems to support everything we need. I'll start with this and if we face any limitations it should be easy to swap into different one.

@sdaveas
Copy link
Contributor Author

sdaveas commented Apr 7, 2021

It turns out that logging in asynchronous systems is less trivial that traditional systems. tracing is a logging library we can use, that is build for sync systems like tokio and also uses log under the hood.

tracing produces log messages from spawned tasks which are then consumed by a subscriber (tracing-subscriber serves that purpose).

@ggutoski
Copy link
Contributor

ggutoski commented Apr 7, 2021

Yikes! Tofn does not have any async code. Is it possible to use something like log or simplelog in tofn? Can we restrict use of async logger only to where it's needed in tofnd?

@sdaveas
Copy link
Contributor Author

sdaveas commented Apr 7, 2021

Yeah, I suppose that we can do that. In terms of complexity things don't seem that bad, though.

fn foo {
    let ctx: &str = ... // creates 'keygen [key] party [A] with (t,n)=(0,2)' str
    let span = span!(Level::INFO, "keygen", ctx);
    error!("keygen failure");
}

So far, the result looks like this

Apr 07 21:41:05.523 ERROR Keygen{msg="keygen [Gus-test-key] party [A] with (t,n)=(0,2)"}: tofnd::gg20: keygen failure

@sdaveas
Copy link
Contributor Author

sdaveas commented Apr 8, 2021

@ggutoski , I recommend to use tracing for tofn logs.

Since tofn is a library and is only called externally, it doesn't have to carry a subscriber to gather logs; it just need to emit them. The only changes that are needed at tofn is to replace println!s with info! (or warn!, etc). If we do that, we get a nice combo of logs in tofnd.

The following is a tofn warning message when running tofnd's tests:

Apr 08 17:42:25.069  WARN Sign:Handle{log="sign [Gus-test-sig] party [uid:A, share:1/2]"}:Protocol{round=0}: tofn::protocol::gg20::sign::protocol: participant 1 overwrite existing R1Bcast msg from 1
                      ^    ^     ^         ---------------------------------------------      ^    --------                                        --------------------------------------------------
                      |    |     |                               |                            |      |                                                                    |
          tofn log type    |  tofnd sub-function <--------- log prefix of                     |   log prefix of                                                     tofn warning message
                           |                                                                  |      |
                           |                                                                  |      v
                      tofnd function                                                    tofnd sub-sub-function

@ggutoski ggutoski mentioned this issue Apr 8, 2021
34 tasks
@sdaveas sdaveas linked a pull request Apr 9, 2021 that will close this issue
@ggutoski ggutoski added this to the Testnet v0.3 milestone Apr 12, 2021
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 a pull request may close this issue.

2 participants