Skip to content

Plugin for loglevel JS lib which will forward all log messages to the server

License

Notifications You must be signed in to change notification settings

foodji/loglevel-serverSend

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Plugin for JS logger loglevel which will forward all log messages to the server

Features

  • Send is async and wouldn't slow down the application
  • Messages send one by one, so the order is maintained
  • Any server which accept POST request should be supported
  • You can specify prefix function which would dynamically add prefix for all log messages (app name, current user, etc.)

Installation

Configuration

Add loglevel and loglevel-serverSend scripts to your page first. Then configure the plugin:

##loglevelServerSend(logger, options) Extend loglevel with new plugin which will send log information to the log-sever

Param Type Description
logger object loglevel instance to be extended
options object
[options.url='http://localhost:8000/main/log'] string Server url which would be used as a log server
[options.prefix=null] string | function Prefix for all log messages. Either string or function wich should return string and accept log severity and message as parameters
[options.callOriginal=false] Bool If set to true - original loglevel method for logging would be called

Example

loglevelServerSend(log,{url:'https://example.com/app/log',prefix: function(logSev,message) {
    return '[' + new Date().toISOString() + '] ' + logSev + ': ' + message + '\n'   
}})

Servers

It should be fairly easy to create a server which will store all the log messages, but most probably node-log-server would be good enough for you

About

Plugin for loglevel JS lib which will forward all log messages to the server

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%