elastic / elastic/ecs-logging-java

Add the possibility to process or transform the message

Aperta
#164 1 commento 2 reazioni 0 assegnatari Vedi su GitHub
agent-java community triage
Lingua principale
Java
Stelle
148
Fork
82
Merge medio
2g 17h
PR unite (30g)
3

Descrizione

I need to be able to transform some messages. For example obfuscate some information. I want to be able to do that at the encoder level and not before on several components.

Now a days, the encode method add the message using
`event.getFormattedMessage()`

It could be very useful if we can add something similar to the following at the ECSEncoder class:

/**
* Subclasses can override this to format the message (for example to obfuscate some fields.)
* @param event The event to be logged
* @return The message processed. By default, this method return the message without any modification
*/
protected String processMessage (ILoggingEvent event){
return event.getFormattedMessage();
}

And at the encode method

`EcsJsonSerializer.serializeFormattedMessage(builder, processMessage(event));`

What do you think?

The method name could be process, transform, or just getMessage...

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.