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
The idea is to extend the logging system by introducing contextual logging capabilities, allowing logs to be structured within hierarchical contexts. This feature is similar to what we do in the ABRoot logger, the difference lies in the different implementation, in ABRoot we used to manually assign an index to each log (introducing a risk of human error):
the new implementation uses a context-based approach:
funcmain() {
logger, err:=NewLogger("myApp")
iferr!=nil {
fmt.Println("Error creating logger:", err)
return
}
rootCtx:=NewLogContext("Function", nil)
subCtx:=NewLogContext("StepName", rootCtx)
logger.InfoCtx(rootCtx, "Entering function")
logger.InfoCtx(subCtx, "Performing a step")
logger.ErrorCtx(subCtx, "Encountered an error")
logger.ErrorCtx(subCtx, "Encountered a second error")
logger.InfoCtx(rootCtx, "Exiting function")
}
The writer will use both files and console based on our current implementation and it will look like almost the same as the ABRoot approach:
Function:info:Entering function
Function:StepName:info:Performing a step
Function:StepName:err(0):Encountered an error
Function:StepName:err(1):Encountered a second error
Function:info:Exiting function
the main difference is that in the new implementation we do not have to manually specify an index for the error since that get's automatically generated ensuring its consistency and progression, while the prefix is automatically constructed by the context.
The text was updated successfully, but these errors were encountered:
The idea is to extend the logging system by introducing contextual logging capabilities, allowing logs to be structured within hierarchical contexts. This feature is similar to what we do in the ABRoot logger, the difference lies in the different implementation, in ABRoot we used to manually assign an index to each log (introducing a risk of human error):
the new implementation uses a context-based approach:
The writer will use both files and console based on our current implementation and it will look like almost the same as the ABRoot approach:
the main difference is that in the new implementation we do not have to manually specify an index for the error since that get's automatically generated ensuring its consistency and progression, while the prefix is automatically constructed by the context.
The text was updated successfully, but these errors were encountered: