kutuluk / loglevel-plugin-remote

A loglevel plugin for sending browser logs to a server
MIT License
102 stars 36 forks source link

Can you provide a snippet of server implementation? #25

Open rshailu opened 4 years ago

rshailu commented 4 years ago

I did something like this

app.post('/logger', (req, res) => {
  console.log(req.body);

});

I am not getting logs in backend.

rshailu commented 4 years ago

Its working now, it seems format is very important. Needed to integrate loglevel with format eg:

const customJSON = log => ({
 msg: log.message,
 level: log.level.label,
 stacktrace: log.stacktrace
});

remote.apply(log, { format: customJSON, url: '/logger' });