1.0.1 • Published 7 years ago

cloud-logger v1.0.1

Weekly downloads
3
License
GPL-3.0
Repository
github
Last release
7 years ago

Cloud-logger

Send and save your logs in cloud.

Code Example

const logger = require('cloud-logger')('my-logger-server.com', {protocol: 'ws', level: 1})
logger.log({type: 'MY_AWESOME_LOG', message: 'I use cloud-logger!'});

Motivation

Often all you need is simple flexible logger that saves everything in your own storage.

Installation

npm install cloud-logger --save

API Reference

Constructor

require('cloud-logger')(connection, options)

connection

String with url - connection to cloud-log-server. e.g. https://gile-log.herokuapp.com/

options

Object with following possible attributes

NameDefault valueDescription
callback-this function will be called after data is logged, arguments are (data,error); see example
callbackTypes array of string, if logged message contains attribute type, which is in this array, callback function will be called
protcolwsprotocol used for posting logs, possible values are 'ws' for websockets and 'http' for standard rest request
level1possible values are 1 - cloud only, 2 - cloud and console, 3 - console only

log(data)

This method sends data to cloud-logger service. Data have to be JSON object.

Example

//creating connection - must be called at first
const options = {
  level: 1,
  protocol: 'ws',
  callbackTypes: ['RESTARTING_APP', 'NEW_USER'],
  callback: (data, err) => {
    if (err) {
      console.log('ERROR!');
      return;
    }
    console.log('I saved this log in cloud', data);
  }
}
const logger = require('cloud-logger')('my-logger-server.com', {protocol: 'ws', level: 1})

//this line will send object to cloud and then call callback defined in options
logger.log({type: 'NEW_USER', message: 'New user added'});
//cloude-logger is already initialized
const logger = require('cloud-logger').logger

Tests

npm run test

License

GPL-3.0

1.0.1

7 years ago

1.0.0

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago