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

Add example for custom logger and LogLevel.toString #253

Merged
merged 2 commits into from
Dec 6, 2022

Conversation

RobertIndie
Copy link
Member

Motivation

Currently, there is no example or documentation to show how to use the custom logger.

Modifications

  • Add an example to show how to use the custom logger
  • Add toString method to Pulsar.LogLevel to convert logLevel number to string

Verifying this change

Run node examples/custom_logger.js

Output:

[INFO][ClientConnection:189] [<none> -> pulsar://localhost:6650] Create ClientConnection, timeout=10000
[INFO][ConnectionPool:97] Created connection for pulsar://localhost:6650
[INFO][ClientConnection:379] [127.0.0.1:50422 -> 127.0.0.1:6650] Connected to broker
[INFO][HandlerBase:72] [persistent://public/default/my-topic, ] Getting connection from pool
[INFO][ProducerImpl:190] [persistent://public/default/my-topic, ] Created producer on broker [127.0.0.1:50422 -> 127.0.0.1:6650] 
[INFO][Client:87] Subscribing on Topic :persistent://public/default/my-topic
[INFO][HandlerBase:72] [persistent://public/default/my-topic, sub1, 0] Getting connection from pool
[INFO][ConsumerImpl:238] [persistent://public/default/my-topic, sub1, 0] Created consumer on broker [127.0.0.1:50422 -> 127.0.0.1:6650] 
my-message
[INFO][ProducerImpl:721] [persistent://public/default/my-topic, standalone-5-19] Closing producer for topic persistent://public/default/my-topic
[INFO][ProducerImpl:687] [persistent://public/default/my-topic, standalone-5-19] Closed producer 0
[INFO][ConsumerImpl:1097] [persistent://public/default/my-topic, sub1, 0] Closing consumer for topic persistent://public/default/my-topic
[INFO][ConsumerImpl:1083] [persistent://public/default/my-topic, sub1, 0] Closed consumer 0
[INFO][ClientImpl:517] Closing Pulsar client with 0 producers and 0 consumers
[INFO][ClientConnection:1584] [127.0.0.1:50422 -> 127.0.0.1:6650] Connection closed with ConnectError
[INFO][ClientConnection:267] [127.0.0.1:50422 -> 127.0.0.1:6650] Destroyed connection

Documentation

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    (Please explain why)

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

@RobertIndie RobertIndie self-assigned this Dec 2, 2022
examples/custom_logger.js Outdated Show resolved Hide resolved
examples/custom_logger.js Show resolved Hide resolved
Co-authored-by: Yunze Xu <xyzinfernity@163.com>
@RobertIndie RobertIndie merged commit 5173415 into apache:master Dec 6, 2022
@RobertIndie RobertIndie added this to the 1.8.0 milestone Dec 20, 2022
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