sirupsen / logrus

Structured, pluggable logging for Go.
MIT License
24.59k stars 2.27k forks source link

support using with tinygo #1387

Closed rajatjindal closed 1 year ago

rajatjindal commented 1 year ago

hello

I am using logrus in a golang wasm project (code here) and when trying to build it using tinygo, I am running into following issue:

$) tinygo build -target=wasi -gc=leaking -no-debug --tags 'tinygo' -o main.wasm main.go
wasm-ld: error: /var/folders/5r/6y6fr12x1dq6qnt74zn4_1wm0000gn/T/tinygo159344941/main.o: undefined symbol: golang.org/x/sys/unix.Syscall
error: failed to link /var/folders/5r/6y6fr12x1dq6qnt74zn4_1wm0000gn/T/tinygo159344941/main: exit status 1
Error: Build command for component goodfirstissue failed with status Exited(1)

I ran into a similar problem using mattn/go-isatty, which is apparently fixed by a similar PR

therefore I am submitting this PR for logurs to allow us to use it with tinygo in a similar fashion.

Kindly let me know if this makes sense. I am happy to answer or implement any feedback that you might have.

Regards Rajat Jindal

rajatjindal commented 1 year ago

requesting review from @sirupsen

sirupsen commented 1 year ago

Can you explain https://github.com/sirupsen/logrus/pull/1388/files vs this PR? @flavio

flavio commented 1 year ago

They are similar. TinyGo and the official Go compiler use a different identifier for the WASI target. TinyGo uses wasi, while the official Go compiler will use wasip1.

I think we could make the two PR conflate into a single one and make it target both GOOS values.

BTW, the usage of the tinygo identifier seems a bit too wide to me. This would identify also a TinyGo binary built for a regular linux/osx/windows system.

rajatjindal commented 1 year ago

I am happy to have my PR closed in favor of #1388 if we want to add support of tinygo there as well. thank you.

flavio commented 1 year ago

I've updated my PR to include tinygo + wasi support

You can see a demo here: https://gist.github.com/flavio/f24fc3f349c09ac134e2e130109488e9

sirupsen commented 1 year ago

merged the other one