1 | # advanced-logger
|
2 |
|
3 | [![Build Status](https://travis-ci.org/AlexeyPopovUA/advanced-logger.svg?branch=master)](https://travis-ci.org/AlexeyPopovUA/advanced-logger)
|
4 | [![npm version](https://badge.fury.io/js/advanced-logger.svg)](https://badge.fury.io/js/advanced-logger)
|
5 | [![dependencies Status](https://david-dm.org/AlexeyPopovUA/advanced-logger/status.svg)](https://david-dm.org/AlexeyPopovUA/advanced-logger)
|
6 | [![install size](https://packagephobia.now.sh/badge?p=advanced-logger)](https://packagephobia.now.sh/result?p=advanced-logger)
|
7 | [![](https://data.jsdelivr.com/v1/package/npm/advanced-logger/badge)](https://www.jsdelivr.com/package/npm/advanced-logger)
|
8 | [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FAlexeyPopovUA%2Fadvanced-logger.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FAlexeyPopovUA%2Fadvanced-logger?ref=badge_shield)
|
9 |
|
10 | [![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=advanced-logger&metric=alert_status)](https://sonarcloud.io/dashboard/index/advanced-logger)
|
11 | [![Reliability](https://sonarcloud.io/api/project_badges/measure?project=advanced-logger&metric=reliability_rating)](https://sonarcloud.io/dashboard/index/advanced-logger)
|
12 | [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=advanced-logger&metric=coverage)](https://sonarcloud.io/dashboard/index/advanced-logger)
|
13 | [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=advanced-logger&metric=bugs)](https://sonarcloud.io/dashboard/index/advanced-logger)
|
14 | [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=advanced-logger&metric=code_smells)](https://sonarcloud.io/dashboard/index/advanced-logger)
|
15 | [![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=advanced-logger&metric=vulnerabilities)](https://sonarcloud.io/dashboard/index/advanced-logger)
|
16 | [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
|
17 |
|
18 | ## What is it?
|
19 |
|
20 | It is an extendable isomorphic log sending library written in TypeScript for javascript application in nodejs and browsers.
|
21 |
|
22 | It can be extended with custom strategy ("when to send logs") and service ("where to send logs").
|
23 |
|
24 | It does not restrict you with conventions, for example, existence of "logSeverity", "ErrorId" or "message" fields in log.
|
25 |
|
26 | It supports any format of logs via custom serializer.
|
27 |
|
28 | ## Features
|
29 |
|
30 | * :scream_cat: It works in browsers and nodejs
|
31 | * :articulated_lorry: It is able to send single logs and bundles of them to an external logger
|
32 | * It supports different log sending strategies:
|
33 | 1. :alarm_clock: interval (for example, every 10 seconds)
|
34 | 2. :loudspeaker: on request (only when you ask)
|
35 | 3. :alarm_clock: :heavy_plus_sign: :loudspeaker: mixed ("interval" + "on request") (will be done soon)
|
36 | 4. :steam_locomotive: :railway_car: :railway_car: :railway_car: on bundle size (for example, sends bundles of 100 logs)
|
37 | 5. :toilet: instant (received 1 log -> sent 1 log)
|
38 | * :busts_in_silhouette: It is able to group duplicated logs in certain time interval (for rapid fire of the same logs)
|
39 | * :octopus: It is not afraid of circular links in log objects
|
40 | * :building_construction: It supports custom format for logs (custom serializer)
|
41 | * :dart: It supports different remote logger endpoints (SumoLogic, Loggly and Elasticsearch). Who is the next? ᕙ(ಠ.ಠ)ᕗ
|
42 |
|
43 | ## Runtime environment support :running_woman:
|
44 |
|
45 | Builds are generated as ES5 bundles for nodejs and browser environments.
|
46 |
|
47 | :robot: NodeJS - tested on latest lts
|
48 |
|
49 | :globe_with_meridians: Browser - all latest browsers + IE10, IE11 (fetch polyfill)
|
50 |
|
51 | ## [Documentation](https://advancedlogger.com "Advanced Logger's Homepage")
|
52 |
|
53 | Complete documentation and examples can be found here:
|
54 |
|
55 | **[Advanced Logger's Homepage](https://advancedlogger.com "Advanced Logger's Homepage")**
|
56 |
|
57 | **[NPM package link](https://www.npmjs.com/package/advanced-logger "NPM package link")**
|
58 |
|
59 | ### Simplest usage
|
60 |
|
61 | Now, the boring part :nerd_face:
|
62 |
|
63 | #### Add to the project
|
64 |
|
65 | In browser:
|
66 |
|
67 | ```html
|
68 | <script src="./node-modules/advance-logger/dist/browser/advanced-logger.browser.min.js"></script>
|
69 | ```
|
70 |
|
71 | or
|
72 |
|
73 | ```html
|
74 | <script src="https://cdn.jsdelivr.net/npm/advanced-logger@latest/dist/browser/advanced-logger.browser.min.js"></script>
|
75 | <script src="https://cdn.jsdelivr.net/npm/advanced-logger@latest/dist/browser-debug/advanced-logger.browser.js"></script>
|
76 | ```
|
77 |
|
78 | In nodejs:
|
79 |
|
80 | ```javascript
|
81 | const {AdvancedLogger, service, strategy} = require('advanced-logger');
|
82 | ```
|
83 |
|
84 | #### Configuration
|
85 |
|
86 | Lets initiate a logger that sends all logs instantly to Sumologic service.
|
87 |
|
88 | In browser
|
89 |
|
90 | ```javascript
|
91 | const {AdvancedLogger, service, strategy} = window.advancedLogger;
|
92 |
|
93 | const defaultLogConfig = {
|
94 | UserAgent: window.userAgent,
|
95 | Channel: "my-company",
|
96 | BuildVersion: 123,
|
97 | Platform: "browser",
|
98 | Severity: "DEBUG",
|
99 | Data: "",
|
100 | Timestamp: "",
|
101 | Message: "",
|
102 | Category: ""
|
103 | };
|
104 |
|
105 | const serviceConfig = {
|
106 | url: "https://www.google.nl",
|
107 | sourceName: "advancedLoggerTest",
|
108 | host: "advanced-logger",
|
109 | sourceCategory: "MY/SUMO/namespace",
|
110 | method: "POST"
|
111 | };
|
112 |
|
113 | const config = {serviceConfig, defaultLogConfig};
|
114 |
|
115 | const logger = new AdvancedLogger({
|
116 | service: new service.SumologicService(config),
|
117 | strategy: new strategy.InstantStrategy()
|
118 | });
|
119 |
|
120 | logger.log({test: "instant log u1"}); // sends log message :rocket:
|
121 | logger.log({test: "instant log u2"}); // sends log message :rocket:
|
122 | logger.log({test: "instant log u3"}); // sends log message :rocket:
|
123 | ``` |
\ | No newline at end of file |