Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/atatus/atatus-winston
Ship winston logs to Atatus
https://github.com/atatus/atatus-winston
Last synced: about 2 months ago
JSON representation
Ship winston logs to Atatus
- Host: GitHub
- URL: https://github.com/atatus/atatus-winston
- Owner: atatus
- License: apache-2.0
- Created: 2024-06-15T12:37:19.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-06-24T08:47:08.000Z (7 months ago)
- Last Synced: 2024-10-31T20:09:18.090Z (2 months ago)
- Language: JavaScript
- Size: 45.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# atatus-winston
`atatus-winston` is a [winston](https://github.com/winstonjs/winston) plugin. With `atatus-winston`, you can take advantage of the winston logger framework with your Node.js app.
### Versions
Supports Winston 3, If you want to use Winston 2 - Checkout v1.0.8
### Add the dependency to your project
```bash
npm install atatus-winston --save
```## Configure atatus-winston
Use the samples in the code block below as a starting point, and replace the sample with a configuration that matches your needs.
To run with **Typescript** [click here](#typescript).```javascript
const winston = require('winston');
const AtatusWinstonTransport = require('atatus-winston');let atatusWinstonTransport = new AtatusWinstonTransport({
apiKey: '',
name: 'atatus-winston',
service: 'payment-service',
source: 'payment-service'
});const logger = winston.createLogger({
format: winston.format.simple(),
transports: [ atatusWinstonTransport ],
});logger.info('Just a test message for Atatus Winston Logger setup');
```Replace `` with your own Atatus [api key](https://docs.atatus.com/docs/faq/basics-faq/where-to-find-api-key.html).
If you do not have a [Atatus](https://www.atatus.com) account, you can sign up for a free trial [here](https://www.atatus.com/signup)
### Logs in my console
The winston logger by default sends all logs to the console.
You can easily disable this by adding this line to your code :```js
winston.remove(winston.transports.Console);
```## Running with Typescript
If you don't have a 'tsconfig.json' file start by running:
```bash
tsc --init
```On your 'tsconfig' file, under 'compilerOptions' make sure you have 'esModuleInterop' flag with the value 'true' or add it this way:
```
"compilerOptions": {
...
"esModuleInterop": true
}
```Code sample:
```ts
import winston from 'winston';
import AtatusWinstonTransport from 'atatus-winston';let atatusWinstonTransport = new AtatusWinstonTransport({
apiKey: '',
name: 'atatus-winston',
service: 'payment-service',
source: 'payment-service'
});const logger = winston.createLogger({
format: winston.format.simple(),
transports: [ atatusWinstonTransport ],
});logger.log('warn', 'Just a test warning message');
```Replace `` with your own Atatus [api key](https://docs.atatus.com/docs/faq/basics-faq/where-to-find-api-key.html).
# Troubleshooting
To fix errors related to "esModuleInterop" flag make sure you run the relavent 'tsconfig' file.
These might help:```
tsc .ts --esModuleInterop
```or
```
tsc --project tsconfig.json
```