You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: google-cloud-pubsub/README.md
+37Lines changed: 37 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,6 +92,43 @@ module GRPC
92
92
end
93
93
```
94
94
95
+
### Enabling library level logging
96
+
97
+
This library includes an opt-in logging mechanism that provides detailed information about high-level operations. These logs are useful for troubleshooting and monitoring the client's behavior. When enabled, logs are tagged with subtags to indicate the operation type.
98
+
99
+
The following subtags are used:
100
+
101
+
*`callback-delivery`: Logs when a message is delivered to the user-provided callback.
102
+
*`callback-exceptions`: Logs any exceptions raised from the user callback.
103
+
*`ack-nack`: Logs when a message is acknowledged (`ack`) or negatively acknowledged (`nack`).
104
+
*`ack-batch`: Logs the reason and size of acknowledgement batches sent to the server.
105
+
*`publish-batch`: Logs the reason and size of message batches sent to the server for publishing.
106
+
*`expiry`: Logs when a message's lease expires and it is dropped from client-side lease management.
107
+
*`subscriber-streams`: Logs key events in the subscriber's streaming connection, such as opening, closing, and errors.
108
+
*`subscriber-flow-control`: Logs when the subscriber's client-side flow control is paused or resumed.
109
+
110
+
**WARNING:** These logs may contain message data in plaintext, which could include sensitive information. Ensure you are practicing good data hygiene with your application logs. It is recommended to enable this logging only for debugging purposes and not permanently in production.
111
+
112
+
To enable these debug logs, you must provide a logger with the `progname` set to `"pubsub"`.
113
+
114
+
```ruby
115
+
require"google/cloud/pubsub"
116
+
require"logger"
117
+
118
+
# Create a logger and set the progname to "pubsub" to enable library-level logging
119
+
logger =Logger.new($stdout)
120
+
logger.progname ="pubsub"
121
+
122
+
# Configure the logger globally
123
+
Google::Cloud.configure.pubsub.logger = logger
124
+
125
+
# Or provide it directly to the client
126
+
pubsub =Google::Cloud::PubSub.newlogger: logger
127
+
```
128
+
129
+
If the logger's `progname` is not set to `"pubsub"`, these debug logs will be suppressed, even if the logger is provided.
0 commit comments