-
Hi there, It looks like this commit #271 allowed users to override the client logging. Here is an example, from the cmd/torrent. -> https://github.com/anacrolix/torrent/blob/master/cmd/torrent/main.go#L321
This Discard object is a global thing, defined as: https://github.com/anacrolix/log/blob/master/global.go#L14
A stream logger is this:
My application is using logrus, and I would like to capture logs and emit them with logrus. So I guess I just need to implement a Log function that takes a msg and print it (with logrus ?). I'll try that.
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
I figured it out, here's what I did: Calling the thing:
Override logic
|
Beta Was this translation helpful? Give feedback.
-
Thanks for contributing that. What do you think of the interface? I'm not especially happy with anacrolix/log, it "bubbles" up log messages in a Context-like chain, but it means that filtering doesn't occur for some time, and there's a fair bit of allocation prior to hitting a filter. Additionally the filters can exist anywhere in the chain, rather than in a single place. It's very flexible, but not practical I think. |
Beta Was this translation helpful? Give feedback.
-
I haven’t thought too much about the interface, as long as I can capture the logs it’s fine for me at this point.
I’ll use analog it sounds better.
I tried using log.Level (the ‘int’) but I was getting some odd errors while the ’string interface worked.
… On Aug 29, 2021, at 6:55 PM, Matt Joiner ***@***.***> wrote:
You might match against the level values rather than their String, for example log.Level. Additionally the silly package name convention for anacrolix/log is analog, if you care to use that. :)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#551 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AC2O6ULR4EJEWCWRLIMBOB3T7LQIXANCNFSM5C34V5RQ>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
-
I've tried but I get this error:
|
Beta Was this translation helpful? Give feedback.
I figured it out, here's what I did:
Calling the thing:
Override logic