Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

initialize rust logs via ffi #13

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

initialize rust logs via ffi #13

wants to merge 1 commit into from

Conversation

lanzafame
Copy link

This is not entirely working just yet. It appears to connect the rust logger to go-log, but there is an issue with closing the file I believe. Help would be appreciated

Copy link

@vmx vmx left a comment

Choose a reason for hiding this comment

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

Please note that the generated.FilInitLogFd() call needs to be the first thing you ever call on the FFI. If you call any FFI method before, then the logger might already be initialized and this call would be a no-op.

Thinking about that, I should probably return an error then.

resp := generated.FilInitLogFd(int32(logFile.Fd()))
resp.Deref()

//TODO: figure out whether generated.FilDestoryInitLogFdResponse needs to be called
Copy link

Choose a reason for hiding this comment

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

Yes, generated.FilDestoryInitLogFdResponse() should be called, it just destroys the response, not the logging or file handler or so.


//TODO: figure out whether generated.FilDestoryInitLogFdResponse needs to be called
defer generated.FilDestroyInitLogFdResponse(resp)
//TODO: figure out how to close the file
Copy link

Choose a reason for hiding this comment

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

Good point. I haven't thought about a way to stop the logging to file, I expected to run "forever", which probably isn't a good idea.

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.

2 participants