I'm working on an angular project in which the HTML is embedded in a device.. not a traditional web browser of a computer. Anyway I need to send a logging mechanism to a host device that is acting as a server of sorts.
I got the service running and it is working. I can send messages back and forth. I need to do a structured logging and was wondering if there are existing packages already available instead of writing my own.
So something like this:
JAVASCRIPT:
export class LogEvent
{
constructor(logLevel: any, messageTemplate: string , exception? : any , args? : any[])
{
this.Level = logLevel;
this.MessageTemplate = messageTemplate;
this.Exception = exception;
if (args) this.Properties = [... args];
}
toString() : string {
//this is what i Need.. to convert props into strings embeded into the
//MessageTemplate
}
}
var someValue = 1234;
var msgT = "A message {someValue}";
var event = LogEvent(verbose, msgT, null, someValue);
var str = event.toString()
// expected str to be 'A message 1234'
the npm pacakage @messageformat/parser will parse the messageTemplate but i havent seen a method to actually create the message with the values inserted into the message template.