Comments (7)
I'm not sure if I understand correctly but does this feature of winston do what you are requesting ?
Could you provide a complete example of your needs ?
from winston-telegram.
Let me know if this is what are you looking for:
const { createLogger, format, transports } = require('winston')
const TelegramLogger = require('winston-telegram')
// Ignore log messages if they have { private: true }
const ignorePrivate = format((info, opts) => {
if (info.private) { return false }
return info
})
const logger = createLogger({
format: format.combine(
ignorePrivate(),
format.json()
),
transports: [
new transports.Console(),
new TelegramLogger({
token: 'TOKEN',
chatId: 'CHAT_ID',
level: 'error',
unique: true
})
]
})
// Outputs: {"level":"error","message":"Public error to share"}
logger.log({
level: 'error',
message: 'Public error to share'
})
// Messages with { private: true } will not be written when logged.
logger.log({
private: true,
level: 'error',
message: 'This is super secret - hide it.'
})
from winston-telegram.
In a way yes but I was more thinking - not to ignore messages, but rather to selectively send them to Telegram, if {private: true}
let's say in this instance. I know at a previous job we had this, just a slack bot instead of TG.
It would be invoked like this: logger.info('Login Success', { channel: '@nico' })
. <-- This would go to channel specified.
But logger.info('cache-hit-1337')
<-- this would only go to console.
The examples are contrived, but hopefully it's clear. 😓
from winston-telegram.
There is an example for NestJS?
from winston-telegram.
Sorry @fr20587 but I'm not familiar with NestJS.
@nicoandmee I'm sorry but I wasn't able to find time to take a look at your proposition for the moment.
from winston-telegram.
@nicoandmee you can try my fork (wip):
https://github.com/WildEgor/winston-telegram
https://github.com/WildEgor/winston-telegram/blob/develop/examples/simple-log/src/index.ts#L26
from winston-telegram.
After checking again @nicoandmee request, from my understanding, I think that there are two things:
- Be able to selectively choose what transport to use to log the message with a unique logger defined. Not possible AFAIK
- Be able to selectively choose what TG chatId should the log message be sent. That is the example from @WildEgor fork.
I'm closing this issue as there wasn't any activity or response since my last comment.
If anyone finds interesting to investigate and implement the second point, fell free to open a new issue.
from winston-telegram.
Related Issues (16)
- Setting log level to warn doesn't work HOT 2
- How to properly handle errors in nuxt ? HOT 7
- How to fix 400 error ? HOT 13
- Multiple Log-Levels HOT 4
- 429: Too Many Requests: retry after 5 HOT 1
- Winston Transport can only be default-imported using the 'esModuleInterop' flag HOT 4
- Split long messages HOT 10
- Unmet Peer Dependency HOT 3
- Output in markdown format? HOT 1
- Please, update dependencies HOT 2
- Update readme HOT 1
- this.handleExceptions = options.handleExceptions ?? true HOT 1
- Bunch of errors HOT 2
- Add a new option for "message_thread_id" in chats HOT 3
- Feature request - message labels HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from winston-telegram.