Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Conversation

bonedaddy
Copy link

I needed this functionality to be able to tail ipfs logs for another project and figured it would probably be useful to others.

I tried using the built in request builder, however it appears that it just continually waits for the call to finish, and given that the log/tail call streams responses, so it just hangs.

@Stebalien
Copy link
Member

Decode decodes and then drains the rest. We'll want something like the pubsub decoder. However, see #180.

@bonedaddy
Copy link
Author

Ah okay, I'll go back to the drawing board and refactor 👌

@bonedaddy
Copy link
Author

Ok I have made the change and tested locally and it works. Really unsure why the ci test are failing, however I don't think its related to this code, as the same problem is effecting your ci build for #180

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with two nits.

logger.go Outdated
return Logger{}, nil
}
if resp.Error != nil {
resp.Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call resp.Output.Close() resp.Close()` drains the stream (needed for other requests where closing early will abort the request.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good point.

logger_test.go Outdated
"testing"
)

func Test_Logger(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: TestLogger

logger.go Outdated

resp, err := s.Request("log/tail").Send(ctx)
if err != nil {
return Logger{}, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the bug, it should return err.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes good catch!

@bonedaddy
Copy link
Author

Ok I believe I've made the fixes. If wanted I can also port this logging stuff over to go-ipfs-http-client later this weekend.

@Stebalien
Copy link
Member

If wanted I can also port this logging stuff over to go-ipfs-http-client later this weekend.

That's mostly for exposing a stable, "core" API so we'll have to think through this a bit. IMO, we should consider simply exposing raw requests and leaving it at that (but I'll let @magik6k make the hard decisions here :)).

@Stebalien Stebalien merged commit 318010d into ipfs:master May 6, 2019
@magik6k
Copy link
Member

magik6k commented May 6, 2019

If wanted I can also port this logging stuff over to go-ipfs-http-client later this weekend.

Logging is rather go-ipfs specific, and afaik there were some plans to rewrite go-log, so the interface might not be too stable.

I want to rewrite most of go-ipfs-api on top of CoreAPI (with things like logging using raw requests if on top of go-ipfs-http-client, erroring if not). I should be able to PR something this week.

Options here are:

  • Wait for go-ipfs-api backed by CoreAPI, use NewCoreShell(httpCoreApi).GetLogs()
  • Add 2 interfaces to interface-go-ipfs-core - one with logging related functions, second with Logging() LoggingAPI, then implement it in http-client, and optionally go-ipfs

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants