You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using typescript in my project, and implemented the exact example:
import * as bunyan from "bunyan";
import RotatingFileStream from "bunyan-rotating-file-stream";
let log = bunyan.createLogger({
name: "foo",
streams: [{
stream: new RotatingFileStream({
path: 'c:/NodeJs/Applications/api-gateway/access.log',
period: '1d', // daily rotation
totalFiles: 30, // keep up to 10 back copies
rotateExisting: false, // Give ourselves a clean file when we start up, based on period
threshold: '10m', // Rotate log files larger than 10 megabytes
totalSize: '20m', // Don't keep more than 20mb of archived log files
gzip: false // Compress the archive log files to save space
})
}]
});
Unfortunately this gives me a type error on the line stream: new RotatingFileStream:
I may be overlooking something, as i am new to TS and JS in general.
Can you please give me a hint in the right direction?
Thanks
Sakis
The text was updated successfully, but these errors were encountered:
Edit: Fixed it by converting to NodeJs.WritableStream, but i don't know if this is the intended way for usage or if theres a "correct" way:
let log = bunyan.createLogger({
name: "API-Gateway",
serializers: {
req: reqSerializer,
res: resSerializer,
body: httpBodySerializer,
err: errSerializer,
},
streams: [
{
stream: new RotatingFileStream({
path: 'c:/NodeJs/Applications/api-gateway/log/access.log',
period: '1d', // daily rotation
totalFiles: 30, // keep up to 10 back copies
rotateExisting: false, // Give ourselves a clean file when we start up, based on period
threshold: '10m', // Rotate log files larger than 10 megabytes
totalSize: '20m', // Don't keep more than 20mb of archived log files
gzip: false // Compress the archive log files to save space
}) as NodeJS.WriteStream
}
]
});
I've actually not used this with typescript. The solution looks like something reasonable from your side, but is definitely a hack, the library needs to change. Is it the TS definitions are wrong?
Yes, that may be the reason because the bunyan stream type doesn't know about the type "RotatingFileStream". I guess it may be correct if the class is deriving from one of the three accepted types, but like i said i am new to JS and TS so i am not sure about this.
I am using typescript in my project, and implemented the exact example:
Unfortunately this gives me a type error on the line
stream: new RotatingFileStream
:I may be overlooking something, as i am new to TS and JS in general.
Can you please give me a hint in the right direction?
Thanks
Sakis
The text was updated successfully, but these errors were encountered: