-
Notifications
You must be signed in to change notification settings - Fork 41
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
Multiple data types / channels support #30
Comments
Just to be clear, is this something that use to work before the upgrade to winston3? If I understand this correctly, you should now be able to pass arbitrary metadata to the Otherwise, looking at the channel implementation it looks like it only support a single channel per logger, so you'd have to create separate loggers, e.g.:
|
Quickly looking at the API and code, I doubt it.
Right, but that arbitary data would be sent to all transports hooked up to winston, so for example, I need the:
All three different event types ' I've created a redis client wrapper which also aggregates (has a) winston logger wrapper which I'm currently usilng to log any ' Thanks for picking up the winston-redis transport anyway @mgibeau :-) |
If you have ideas on how we could, and whether in face we should, extend this transport to work for this type of scenario I'm all ears, but it may be convoluting the transport to much? I don't know, what do you think? |
Thanks, I think I understand better now... Would you be okay with having multiple Winston loggers instances? You could go with an approach like: import winston, { createLogger, format, transports } from "winston";
import redisTransport from "winston-redis";
class MyLogger {
constructor() {
this.messageLogger = createLogger({
format: format.timestamp(),
transports: [
new transports.Console(options),
new transports.File(options)
]
})
this.progressLogger = createLogger({
format: format.timestamp(),
transports: [new redisTransport({
host: 'localhost',
port: 6379,
channel: 'progress'
})]
})
this.bugLogger = createLogger({
format: format.timestamp(),
transports: [new redisTransport({
host: 'localhost',
port: 6379,
channel: 'bug'
})]
})
}
message(text) {
return this.messageLogger.info(text)
}
progress(percent) {
return this.progressLogger.info(percent)
}
bug(count) {
return this.bugLogger.info(count)
}
} Then you can use it as: MyLogger.message('Starting process...')
MyLogger.progress(55)
MyLogger.bug(3) On the other hand, I haven't used the channel option yet, but I think having the liberty to define a channel per message would be useful. It would allow using a single Redis connection (and logger instance) to publish across multiple channels. Hopefully, that makes sense? Let me know if you think it's worthwhile to implement or if I'm still completely off track :) |
Multiple loggers could be OK (currently I have one logger and one redis client), each logger needs to support multiple channels also. Loggers for example, with the channels they need to supportThere could be many more channels, this depends on how many test sessions a user wants, each test session can have many routes that a user wants to test. For the purpose of this discussion, just know that there can be many channels
I need the ability to dictate event type, channel, transport per message. event type: Currently I'm pushing events to my
There's a good number of examples of how There are a couple of examples of how
Am I making sense? |
If you're okay with multiple loggers, I would be willing to implement support for specifying a channel per message. Changing the transport seems like something that would need to happen upstream in winston itself. |
Yeah, that's what I was thinking, so unlikely to happen. Thanks for your feedback @mgibeau :-) |
It looks like the transport doesn't quite fit my requirements of pushing three (at this stage) types of data:
All of which will be sent on three different channels minimum at different times, in the form of:
{ id: update.timestamp, event: update.event, data: update.data }
which is consumed by subscribbers converting the messages into server sent events (SSE) (AKA EventSource) to be sent to a CLI somewhere on the internet.
Originally posted by @binarymist in #29 (comment)
The text was updated successfully, but these errors were encountered: