Skip to content

Possibility to override/opt out from console logs#79

Merged
dentarg merged 4 commits intocloudamqp:mainfrom
KristjanTammekivi:console-opt-out
Jul 31, 2023
Merged

Possibility to override/opt out from console logs#79
dentarg merged 4 commits intocloudamqp:mainfrom
KristjanTammekivi:console-opt-out

Conversation

@KristjanTammekivi
Copy link
Copy Markdown
Contributor

@KristjanTammekivi KristjanTammekivi commented Jul 26, 2023

This is just #62 with rebase done

Close #62


Original description from #62

This library uses console a lot, without ways to opt out from it or let the consumer provides its own logging implementation (eg. using winston or debug).

This PR makes it possible to do so while:

  1. not introducing dependencies
  2. not changing existing contracts

Example

const client = new AMQPClient('amqp://...');

// opt out
client.logger = null; 

// override
client.logger = {
 debug: (msg, ...params) => { /* custom impl */},
 info: (msg, ...params) => { /* custom impl */},
 warn: (msg, ...params) => { /* custom impl */},
 error: (msg, ...params) => { /* custom impl */},
}

@dentarg dentarg requested a review from carlhoerberg July 26, 2023 12:58
@dentarg
Copy link
Copy Markdown
Member

dentarg commented Jul 27, 2023

Tried it with https://github.com/winstonjs/winston, worked for me 👍

@dentarg dentarg changed the title Console opt out Possibility to override/opt out from console logs Jul 31, 2023
@dentarg dentarg merged commit dba5781 into cloudamqp:main Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants