Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LOG-8039 update packages #59

Merged
merged 18 commits into from Apr 6, 2020
@@ -8,11 +8,8 @@ A [Loggly][0] transport for [winston][1].

A client implementation for Loggly in node.js. Check out Loggly's [Node logging documentation](https://www.loggly.com/docs/nodejs-logs/) for more.

## Looking for `winston-loggly-bulk@3.x` documentation?

Please note that the documentation below is for `winston-loggly-bulk@2.x`. [Read the winston-loggly-bulk@3.x documentation](https://github.com/loggly/winston-loggly-bulk/tree/3.x).

## Usage

``` js
var winston = require('winston');
@@ -25,13 +22,11 @@ Please note that the documentation below is for `winston-loggly-bulk@2.x`. [Read
winston.add(new Loggly({options}));
```

The Loggly transport is based on [Nodejitsu's][2] [node-loggly][3] implementation of the [Loggly][0] API. If you haven't heard of Loggly before, you should probably read their [value proposition][4]. The Loggly transport takes the following options. Either 'inputToken' or 'inputName' is required:
The Loggly transport is based on [Nodejitsu's][2] [node-loggly][3] implementation of the [Loggly][0] API. If you haven't heard of Loggly before, you should probably read their [value proposition][4]. The Loggly transport takes the following options.

* __level:__ Level of messages that this transport should log.
* __subdomain:__ The subdomain of your Loggly account. *[required]*
* __auth__: The authentication information for your Loggly account. *[required with inputName]*
* __inputName:__ The name of the input this instance should log to.
* __inputToken:__ The input token of the input this instance should log to.
* __token:__ The access token (previously inputToken) *[required]*
* __auth__: The authentication information for your Loggly account.
This conversation was marked as resolved by michal-bures

This comment has been minimized.

@michal-bures

michal-bures Mar 26, 2020

This is normally not needed right? Actually is basic auth supported at all anymore? I recommend testing it and if it doesn't work remove this.

Especially since "token" is required, there seems to be no point in entering username/password

This comment has been minimized.

@alestrunda

alestrunda Mar 26, 2020
Author

Again the package uses node-loggly-bulk and there are both token and auth. Token is required, auth seems to be useless, but still I wasn't sure whether it's save to remove it completely.

* __json:__ If true, messages will be sent to Loggly as JSON.
* __tags:__ An array of tags to send to loggly.
* __isBulk:__ If true, sends messages using bulk url
@@ -43,13 +38,11 @@ The Loggly transport is based on [Nodejitsu's][2] [node-loggly][3] implementatio
- __Note:__ Library includes timestamp by default when we do not set timestamp option.
* __networkErrorsOnConsole:__ The library keep track of different network errors and can log them to console. By default, logging errors on console is disabled and can be enabled easily by setting this parameter's value to `true`. If true, all the network errors will be logged to console.

*Metadata:* Logged in suggested [Loggly format][5]

## Sample Working Code Snippet

``` js
var winston = require('winston');
var {Loggly} = require('winston-loggly-bulk');
var { Loggly } = require('winston-loggly-bulk');
winston.add(new Loggly({
token: "TOKEN",
@@ -66,12 +59,14 @@ winston.log('info', "Hello World from Node.js!");
This library has buffer support during temporary network outage. User can configure size of buffer (no. of logs to be stored during network outage).

Add these below configuration in code snippet to override the default values of buffer option __size__ and __retriesInMilliSeconds__.

``` js
bufferOptions: {
size: 1000,
retriesInMilliSeconds: 60 * 1000
size: 1000,
retriesInMilliSeconds: 60 * 1000
}
```

* __Note:__ The default value of buffer size and retries in milliseconds are 500 and 30000 (30 seconds) respectively.

## Flush logs and exit
@@ -82,77 +77,46 @@ Here is an example of how to use the method:

``` js
var winston = require('winston');
var {flushLogsAndExit} = require('winston-loggly-bulk');
var { flushLogsAndExit } = require('winston-loggly-bulk');
winston.log("info", "Hello World from Node.js!");
flushLogsAndExit();
```

## Motivation

`tldr;?`: To break the [winston][1] codebase into small modules that work together.

The [winston][1] codebase has been growing significantly with contributions and other logging transports. This is **awesome**. However, taking a ton of additional dependencies just to do something simple like logging to the Console and a File is overkill.

## Installation

### Installing npm (node package manager)

``` bash
$ curl http://npmjs.org/install.sh | sh
```

### Installing winston-loggly-bulk

If you are running npm version 3 or higher then run the below command to setup the logging-

``` bash
$ npm install winston-loggly-bulk
npm install winston-loggly-bulk
```

If you are running npm version 2 or lower then run the below command to setup the logging-

``` bash
$ npm install winston-loggly-bulk winston
```
* __Note:__ To check the currrent npm version run the below command-
Note: If you are using npm version 2, please run the below command:

``` bash
$ npm -v
npm install winston-loggly-bulk winston
```

## Run Tests
All of the winston tests are written in [vows][6], and cover all of the use cases described above. You will need to add valid credentials for the various transports included to test/config.json before running tests:

``` js
{
"transports": {
"loggly": {
"subdomain": "your-subdomain",
"inputToken": "really-long-token-you-got-from-loggly",
"auth": {
"username": "your-username",
"password": "your-password"
}
}
}
}
```

Once you have valid configuration and credentials you can run tests with [npm][7]:
Written in Jest. Testing that log events are correctly passed on.

```
``` bash
npm test
```

#### Author: [Charlie Robbins](http://www.github.com/indexzero)

#### Contributors: [Loggly](http://github.com/loggly), [Shweta Jain](http://github.com/shwetajain148),

[0]: http://loggly.com
[1]: https://github.com/flatiron/winston
[1]: https://github.com/winstonjs/winston
[2]: http://nodejitsu.com
[3]: https://github.com/nodejitsu/node-loggly
[4]: http://www.loggly.com/product/
[5]: http://www.loggly.com/docs/automated-parsing/
[6]: http://vowsjs.org
[7]: http://npmjs.org
[5]: http://vowsjs.org
[6]: http://npmjs.org
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.