oneuptime/log-js/README.md

124 lines
3.7 KiB
Markdown
Raw Normal View History

2020-06-12 14:41:56 +00:00
# Fyipe Application Logger
A fyipe application logger that can be used to send logs about your applications created on your fypie dashboard
## Installation
2020-06-12 15:03:13 +00:00
### NPM Install
2020-06-19 09:21:52 +00:00
You can install to use in your project:
```
$ cd project
$ npm install fyipe-log-js
```
2020-06-12 15:03:13 +00:00
2020-06-12 14:56:47 +00:00
### Development
2020-06-19 09:21:52 +00:00
- Clone repository
- run `npm i` to install dependencies
- run `npm run test` to run tests
- run `npm run build` to build for production.
2020-06-12 14:41:56 +00:00
<a name="module_api"></a>
## Basic Usage
```javascript
import Logger from 'log-js';
// constructor
2020-06-19 09:21:52 +00:00
const logger = new Logger(
2020-06-29 20:31:43 +00:00
'API_URL', // https:fyipe.com/api
2020-06-19 09:21:52 +00:00
'APPLICATION_LOG_ID',
'APPLICATION_LOG_KEY'
);
2020-06-12 14:41:56 +00:00
// Sending a string log to the server
const item = 'This is a simple log';
2020-06-30 16:01:37 +00:00
logger.log(item); // returns a promise
2020-06-12 14:41:56 +00:00
// Sending a JSON object log to the server
const item = {
user: 'Test User',
page: {
title: 'Landing Page',
loadTime: '6s',
2020-06-19 09:21:52 +00:00
},
};
2020-06-30 16:01:37 +00:00
logger.log(item); // returns a promise
2020-06-12 14:41:56 +00:00
```
## API Documentation
Main API to send logs to the server.
**Author**: HackerBay, Inc.
2020-06-19 09:21:52 +00:00
- [Fyipe Application Logger](#fyipe-application-logger)
- [Installation](#installation)
- [NPM Install](#npm-install)
- [Development](#development)
- [Basic Usage](#basic-usage)
- [API Documentation](#api-documentation)
- [new Logger(apiUrl, applicationId, applicationKey)](#new-loggerapiurl-applicationid-applicationkey)
- [logger.log(log)](#loggerloglog)
- [logger.warning(log)](#loggerwarninglog)
- [logger.error(log)](#loggererrorlog)
- [TODO](#todo)
2020-06-12 14:41:56 +00:00
<a name="logger_api--logger"></a>
2020-06-16 10:53:47 +00:00
### new Logger(apiUrl, applicationId, applicationKey)
2020-06-12 14:41:56 +00:00
2020-06-19 09:21:52 +00:00
Create a constructor from the class, which will be used to send logs to the server.
2020-06-12 14:41:56 +00:00
2020-06-19 09:21:52 +00:00
**Kind**: Constructor
2020-06-12 14:41:56 +00:00
**Returns**: <code>null</code>
2020-06-19 09:21:52 +00:00
| Param | Type | Description |
| -------------- | ------------------- | ------------------------ |
| apiUrl | <code>string</code> | The Server URL. |
| applicationId | <code>string</code> | The Application Log ID. |
| applicationKey | <code>string</code> | The Application Log Key. |
2020-06-12 14:41:56 +00:00
#### logger.log(log)
Logs a request of type `info` to the server.
**Kind**: method of [<code>new Logger</code>](#logger_api--logger)
**Returns**: <code>Promise</code> - A promise response of a success or failure.
2020-06-19 09:21:52 +00:00
| Param | Type | Description |
| ----- | ------------------------------------------ | ---------------------------------------- |
| log | <code>string</code> \| <code>Object</code> | The content to the logged on the server. |
2020-06-12 14:41:56 +00:00
2020-06-16 10:53:47 +00:00
#### logger.warning(log)
Logs a request of type `warning` to the server.
**Kind**: method of [<code>new Logger</code>](#logger_api--logger)
**Returns**: <code>Promise</code> - A promise response of a success or failure.
2020-06-19 09:21:52 +00:00
| Param | Type | Description |
| ------- | ------------------------------------------ | ---------------------------------------- |
| warning | <code>string</code> \| <code>Object</code> | The content to the logged on the server. |
2020-06-16 10:53:47 +00:00
#### logger.error(log)
Logs a request of type `error` to the server.
**Kind**: method of [<code>new Logger</code>](#logger_api--logger)
**Returns**: <code>Promise</code> - A promise response of a success or failure.
2020-06-19 09:21:52 +00:00
| Param | Type | Description |
| ----- | ------------------------------------------ | ---------------------------------------- |
| error | <code>string</code> \| <code>Object</code> | The content to the logged on the server. |
2020-06-16 10:53:47 +00:00
2020-06-12 14:47:40 +00:00
## TODO
2020-06-19 09:21:52 +00:00
- Tags
- TBD