I am developing in Go language, echo framework.
I am designing a logger and I want to log the equivalent of thread ID to the log, but I do not know a good method.
For example, if login processing is performed at the same time with multiple accesses, it succeeds on one side and fails on one side It can not be determined by looking at the log which failed.
After examining, in Go language goroutine's id exists, but I should not get it, Originally it was said that goroutine was not the same in the same thread.
How can I identify threads? Or is there a package to put them in the log?
I'm sorry if I used the wrong expression as English is not my mother tongue. Thanks.
There is no equivalent of thread id in GoLang for go routines.
What you may do is create a context and attach a unique id (request id preferably) to it.Let all the functions accept a context aswell. Let the logger library take the context and print the unique id. By using context in this way you can share even for info for the log
I personally prefer log4j in go Log4J in Go.
It's quite easy to use and also it has all the facilities such as file rotation on the basis of time and size. Also, you can store complete error stack which contains the file name and line number.