@winston-transports/firestore
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

@winston-transports/firestore

Firestore transport for winston logger

npm version

Installing @winston-transports/firestore

npm i @winston-transports/firestore

Usage

import { getFirestore } from 'firebase-admin/firestore';
import { WinstonFirestore } from '@winston-transports/firestore';
import winston, { format } from 'winston';

.....
const firestoreDB = getFirestore();
.....

const logger = winston.createLogger({
	level: 'info',
	transports: [
		.....
		new WinstonFirestore({
            // Firestore reference
			db:firestoreDB,                    
            // Path of collection EX: "Logs" or "Logs/docId/CollectionName"
            // Should path end of collectionName not docId
			collectionPath: 'Logs', 
		})
		.....
	]
});

logger.info('Hello World', {
	meta1: 1,
	meta2: 'string',
	meta3: {deepObj: 1}
});

Typescript Support

@winston-transports/firestore comes with its' own type definitions, so you wont have to use DefinitelyTyped

Dealing with TypeScript issues

You may encounter TypeScript errors when including the transformer, which can be fixed by modifying the TypeScript config.

For a 'TransportStream' error:

Argument of type 'LogtailTransport' is not assignable to parameter of type 'TransportStream'.
Type 'LogtailTransport' is missing the following properties from type 'TransportStream': writable, writableEnded, writableFinished, writableHighWaterMark, and 29 more. 

Modify tsconfig.json with:

"moduleResolution": "node",
"esModuleInterop": true 

Author: Ahmed Eid

Package Sidebar

Install

npm i @winston-transports/firestore

Weekly Downloads

5

Version

1.0.7

License

MIT

Unpacked Size

8.24 kB

Total Files

6

Last publish

Collaborators

  • ahmedeid