Skip to content
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

disable warns on failure / custom logger #381

Closed
rafipiccolo opened this issue Nov 9, 2021 · 3 comments · Fixed by #382
Closed

disable warns on failure / custom logger #381

rafipiccolo opened this issue Nov 9, 2021 · 3 comments · Fixed by #382
Milestone

Comments

@rafipiccolo
Copy link

Proposal:
I would like to disable warnings of write failure or at least provide a logger function to the package so i would be able to handle the warnings correctly.

Current behavior:
currently it fills my logs with big stacks where a custom logger function would be so much useful

WARN: Write to InfluxDB failed (attempt: 1). w [RequestTimedOutError]: Request timed out
    at ClientRequest.<anonymous> (file:///root/docker/check/node_modules/@influxdata/influxdb-client/dist/index.mjs:15:10709)
    at ClientRequest.emit (node:events:390:28)
    at TLSSocket.emitRequestTimeout (node:_http_client:763:9)
    at Object.onceWrapper (node:events:509:28)
    at TLSSocket.emit (node:events:402:35)
    at TLSSocket.Socket._onTimeout (node:net:501:8)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)

Desired behavior:
For exemple

function logger(data) {
    console.log('warning', data);
}
const writeApi = new InfluxDB({url, token, logger})

Use case:
handle correctly failures / stop filling my logs.

@rafipiccolo rafipiccolo changed the title disable warns on failure disable warns on failure / custom logger Nov 9, 2021
@sranka
Copy link
Contributor

sranka commented Nov 9, 2021

Thank you @rafipiccolo for using the client and posting an issue. Use this:

const {setLogger} = require('@influxdata/influxdb-client')

setLogger({
  error(message, error) {
    console.error('ERROR: ' + message, error ? error : '')
  },
  warn(_message, _error) {
    // your custom code herein
  },
})

@sranka
Copy link
Contributor

sranka commented Nov 9, 2021

The generated documentation (and code) should be changed to make it clear.

@rafipiccolo
Copy link
Author

thanks :)

@bednar bednar added this to the 1.21.0 milestone Nov 10, 2021
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 a pull request may close this issue.

3 participants