# winston-google-spreadsheet

> Log data into your Google Spreadsheet with [winston][0] logger modules.

Latest version **0.0.5** (published 2013-09-24) · 0 weekly downloads

## Install

```sh
npm install winston-google-spreadsheet
pnpm add winston-google-spreadsheet
yarn add winston-google-spreadsheet
bun add winston-google-spreadsheet
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2013-09-24 |
| First published | 2013-08-07 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Masashi Katsumata |
| Maintainers | wf9a5m75 |
| Keywords | logging, winston, google, spreadsheet |

## Links

- npm: https://www.npmjs.com/package/winston-google-spreadsheet
- Repository: https://github.com/wf9a5m75/winston-google-spreadsheet
- npm.io page: https://npm.io/package/winston-google-spreadsheet

## Dependencies (5)

- [request](https://npm.io/package/request.md) ~2.26.0
- [data2xml](https://npm.io/package/data2xml.md) ~0.8.1
- [zoneinfo](https://npm.io/package/zoneinfo.md) ~0.1.8
- [refresh-token](https://npm.io/package/refresh-token.md) ~0.0.1
- [googleclientlogin](https://npm.io/package/googleclientlogin.md) ~0.2.6

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.0.5 (latest) — 2013-09-24
- 0.0.4 — 2013-08-09
- 0.0.3 — 2013-08-08
- 0.0.2 — 2013-08-08
- 0.0.1 — 2013-08-07

## README

# winston-google-spreadsheet

Log data into your Google Spreadsheet with [winston][0] logger modules.

## Usage
``` js
  var winston = require('winston');
  
  //
  // Requiring `winston-google-spreadsheet` will expose 
  // `winston.transports.GoogleSpreadsheet`
  //
  require('winston-google-spreadsheet').GoogleSpreadsheet;
  
  winston.add(winston.transports.GoogleSpreadsheet, options);
```

This transport accepts the follow options:

* __fileId:__ (Default **None**) The file ID of Google Spreadsheet that you want to log.
* __sheetIdx:__ (Default **1**) The worksheet index of the file.
* __accessToken:__ (Default **None**) The access token to the file.
* __level:__ (Default **Info**) Level of messages that this transport should log.
* __timezone:__ (Default **Node**) Specify timezone for log timestamp.

In addition for OAuth2, this module also accepts the following options.

* __refreshToken:__ (Default **None**) OAuth2 refresh token.
* __clientId:__ (Default **None**) OAuth2 client ID.
* __clientSecret:__ (Default **None**) OAuth2 client secret.

If you want to use client login, this module also accepts the following options.

* __email:__ (Default **None**) Your gmail address.
* __password:__ (Default **None**) Your gmail password. 

*Metadata:* Logged as JSON literal in cell

*fileId:* A file ID is included in the URL of the file.
![image2](https://github.com/wf9a5m75/winston-google-spreadsheet/raw/master/images/file_id.png)

## Installation

### Installing winston-google-spreadsheet

``` bash
  $ npm install winston
  $ npm install winston-google-spreadsheet
```

### Create a log file
Create a Google Spreadsheet in your Google Drive, then add __timestamp__, __level__, __message__ and __meta__ columns like this image.

![image1](https://github.com/wf9a5m75/winston-google-spreadsheet/raw/master/images/columns.png)

### Client Login

``` js
const EMAIL = 'your@gmail.com';
const PASSWORD = 'your_password';
const FILE_ID = 'your_file_id';

var winston = require('winston');
require('winston-google-spreadsheet').GoogleSpreadSheet;

var ssLogger = new (winston.transports.GoogleSpreadsheet)({
      'email': EMAIL,
      'password': PASSWORD,
      'fileId' : FILE_ID,
      'level' : 'info'
    });

var logger = new (winston.Logger)({
  'transports': [ssLogger],
  'exceptionHandlers': [ssLogger],
  'exitOnError': true
});

logger.log('info', 'Test Log Message', { anything: 'This is metadata' });
```


### OAuth2

``` js
const REFRESH_TOKEN = 'your_refresh_token';
const CLIENT_ID = 'your_client_id';
const CLIENT_SECRET = 'your_client_secret';
const FILE_ID = 'your_file_id';

var winston = require('winston');
require('winston-google-spreadsheet').GoogleSpreadSheet;

var ssLogger = new (winston.transports.GoogleSpreadsheet)({
  'fileId' : FILE_ID,
  'level' : 'info',
  'refreshToken': REFRESH_TOKEN,
  'clientId': CLIENT_ID,
  'clientSecret': CLIENT_SECRET
});
  
var logger = new (winston.Logger)({
  'transports': [ssLogger],
  'exceptionHandlers': [ssLogger],
  'exitOnError': true
});

logger.log('info', 'Test Log Message', { anything: 'This is metadata' });
```


### Change time zone
If you send your log data from in different time zones, you can specify time zone for log timestamp.

``` js
var ssLogger = new (winston.transports.GoogleSpreadsheet)({
  'fileId' : FILE_ID,
  'level' : 'info',
  'timezone': 'America/Los_Angeles'  // Asia/Tokyo etc.
});
```

*See more detailed explain at http://masashi-k.blogspot.com/2013/08/logging-data-into-google-spreadsheet.html*

#### Author: [Masashi Katsumata](http://masashi-k.blogspot.com/)

[0]: https://github.com/flatiron/winston
[1]: https://github.com/TooTallNate/node-time

---
_Source: https://npm.io/package/winston-google-spreadsheet · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
