Git Product home page Git Product logo

logtail-js's Introduction

Logtail - JavaScript Logging Made Easy

Logtail dashboard

ISC License npm version npm version npm version

Collect logs from both the Node.js backend and your frontend.

Logtail is a hosted service that centralizes all of your logs into one place. Allowing for analysis, correlation and filtering with SQL. Actionable Grafana dashboards and collaboration come built-in. Logtail works with any language or platform and any data source.

Features

  • Simple integration. Allows for both backend and frontend logging.
  • Support for structured logging and events.
  • Automatically captures useful context.
  • Performant, light weight, with a thoughtful design.

Supported language versions

  • Node.js 12 or newer

Installation

Backend only

Install Logtail library for your Node.js backend code using the npm package manager:

npm install @logtail/node

Then you can either require it or import it into your codebase:

// require logtail class
const { Logtail } = require("@logtail/node");

// or import if you're using ES modules:
import { Logtail } from "@logtail/node";

Frontend only

Install Logtail library for your frontend code using the npm package manager:

npm install @logtail/browser

Then import the Logtail class:

// import logtail class
import { Logtail } from "@logtail/browser";

Another option is to use Content Delivery Network (CDN). You can import Logtail using the CDN by adding the following line into a page header:

<script src="https://unpkg.com/browse/@logtail/browser@latest/dist/umd/logtail.js"></script>

Both backend and frontend

If your project contains both Node.js backend code and frontend code as well, you can use the universal package @logtail/js which combines the node and browser packages:

First, install the Logtail library using the npm package manager:

npm install @logtail/js

Then import or require it in your code:

// in your backend code:
const { Node: Logtail } = require("@logtail/js");

// in your frontend code:
import { Browser as Logtail } from "@logtail/js";

Example project

To help you get started with using Logtail in your projects, we have prepared a simple program that showcases the usage of Logtail logger. Before proceeding make sure you have npm and Node.js installed.

Download and install the example project

You can download the example project from GitHub directly or you can clone it to a select directory. Then run the following command to install all dependencies (@logtail/js):

npm install

Run the example project

To run the example application, simply run the following command:

node index.js <source-token>

Don't forget to replace with your actual source token which you can find by going to logtail.com -> sources -> edit.

You should see the following output:

Output:
All done! You can check your logs now.

This will generate a total of 4 logs, which will be displayed in your Logtail live tail view.

Explore how example project works

Learn how to setup JavaScript logging by exploring the workings of the example project in detail.


Get in touch

Have any questions? Please explore the Logtail documentation or contact our support.

logtail-js's People

Contributors

adikus avatar gyfis avatar jendatovarys avatar jigglyjams avatar simonrozsival avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.