glg icon indicating copy to clipboard operation
glg copied to clipboard

Log the context

Open spolischook opened this issue 2 years ago • 2 comments

🚀Log the context

Description: There are many different contexts that we need to log along with basic log message

### Issue with current implementation 

At BajaBikes, we used glg to log app executions in many different contexts:
- User, admin, demon execution processes
- lambda, cube, local 
- dev, staging, production
Some of that contexts, e.g. last one, could implemented by separate logging endpoints and\or writers
But others should be added to log as part of the logging.  
E.g. [Elastic Common Schema (ECS)](https://www.elastic.co/guide/en/ecs/current/index.html) 
has a rich schema that can complete log context in many ways. 

### Applicable Solution

Use json format only for one (LogstashWriter) writer  
In writer before send our logs we can Unmarshal log, add contexts and then Marshal it back.  
We can use json format only for all writers all together, that is not trully readable (e.g. for a console)

Another solution will be allow add context to log somehow, or allow define custom structure for a logs,  
but I can't imagine an implementation for now.

### Alternative solution

For now, we are using text format, that we parse in writer by regular expresion, complete structure with contexts, 
marshal it and send to the logstash. 
It's fine for now, but maybe you can get sugestions to make more powerful architecture

spolischook avatar Jul 04 '22 22:07 spolischook

@spolischook Am I correct that you want to display console logs in Raw format as currently, but allow logging in JSON format for certain Writers?

kpango avatar Jul 06 '22 01:07 kpango

@spolischook Am I correct that you want to display console logs in Raw format as currently, but allow logging in JSON format for certain Writers?

that's right. in that case parsing logs will be much easier task

spolischook avatar Jul 06 '22 06:07 spolischook