You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to understand once I have setup the logger I want to use it in other parts of the code, like Handlers, service layers, models etc. For this reason I exported a function GetLoggerInstance() in hope that I can use same logger instance in whole code. But I land up in cyclic dependency. Moreover, when I am to use logging methods the correct context of the log must be picked up.
[19:01:49 IST 2023/07/26] [DEFAULT] [INFO] (myapp/util/config:8) Setting project directory as.....
I understand the access logs and different from application logs, but how can I achieve the parity between both of them using iris logger. Unfortunately I was not able to understand this from Docs. Any help is much appreciated. @kataras
The text was updated successfully, but these errors were encountered:
HI @kataras
This is the easiest approach and I am already using this in my handlers/where-ever the ctx object is available.
I question was regarding how can I get logger instance where I don't have context object. I don't think passing either logger or ctx instance is a good idea.
@ce-ankur If you use the default Iris logger you can get the logger instance through golog.Default/golog.Debug/Info... so you don't have dependency cycle.
Env Details:
I am trying to setup my new Iris application as follows:
The bootstrap.go looks like below:
I want to understand once I have setup the logger I want to use it in other parts of the code, like Handlers, service layers, models etc. For this reason I exported a function
GetLoggerInstance()
in hope that I can use same logger instance in whole code. But I land up in cyclic dependency. Moreover, when I am to use logging methods the correct context of the log must be picked up.I understand the access logs and different from application logs, but how can I achieve the parity between both of them using iris logger. Unfortunately I was not able to understand this from Docs. Any help is much appreciated. @kataras
The text was updated successfully, but these errors were encountered: