Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

logzio-client-side

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logzio-client-side

A logger for the client-side. Using Lgzio client-side logger is a secured way to log info, debug, error and warning messages from your front-end. This logger will send all your front-end logs to your backend and then to Logz.io.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Logzio Client-side Logger

A logger for the client-side. Using Lgzio client-side logger is a secured way to log info, debug, error and warning messages from your front-end. This logger will send all your front-end logs to your backend and then to Logz.io.

client-side-architecture

Install

npm logzio-client-side

Setting the client-side logger

Import and build the logger on your client-side, as the following example:

import * as logzioLogger from 'logzio-client-side'

const logger = logzioLogger.Logger({
  url: `http://<<your url>>api/log`
});

Parameters:

ParameterDescription
url (required)Url to send logs to.
prefixprefix to add to all logs, delete if not needed
log LevelLog level to display in the browser console, from: ERROR, WARN, INFO. Defaults to 'WARN' and 'ERROR'
flushIntervalInterval to flush logs to server

For an example of an elaborate logger configuration see our app demo.

Usage of the logger on the client-side:

    logger.info('this is an info log');
    logger.debug('this is a debug log');
    logger.warn('this is a warning log');
    logger.error('this is an error log');
    logger.flush();

Setting the server-side logger

Add the following code to your server side and change the parameters below:

const logzioServerLogger = require('logzio-client-side/server');
const app = logzioServerLogger.app;
const bodyParser = logzioServerLogger.bodyParser;
const port = <<port>>;

 const logzioShipper = logzioServerLogger.logzioLogger.createLogger({
    token: <<logzio-shipping-token>>,
    host: <<logzio-host>>,
    type: "logzio-client-side",
    debug: true
 });

app.use(bodyParser.json());

app.use(logzioServerLogger.expressEndpoint({
    uri: '/api/log', // Just an example
    logger: logzioShipper,
    enableCors: true
}));

app.listen(port, () => {
    console.log(`Listening at http://localhost:${port}`)
})

Parameters

General
ParameterDescription
port (required)The port you are sending your logs to.
Logzio Shipper
ParameterDescription
logs-shipping-token (required)Add the log shipping token for the relevant Logz.io account. This is the account you want to ship to.
logzio-host (required)Use the listener URL specific to the region of your Logz.io account. You can look it up here.
Logzio Server Logger
ParameterDescription
uri (required)URI to recieve logs at
enableCorsEnable cross-origin requests to your logging endpoint

For more configuration of the logzio-nodejs logger go to our docs. For an example of an elaborate logger configuration see our server demo.

Changelog

  • 1.0.2: Using 'require' for back-end
  • 1.0.0: Create logzio-client-side logger

Keywords

FAQs

Package last updated on 01 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc