@@ -71,6 +71,61 @@ in the documented item's signature.
7171Builder withLimit(int limit) {
7272```
7373
74+ ### Logs
75+
76+ We use SLF4J ; loggers are declared like this :
77+
78+ ```java
79+ private static final Logger LOG = LoggerFactory . getLogger(TheEnclosingClass . class);
80+ ```
81+
82+ Logs are intended for two personae:
83+
84+ * Ops who manage the application in production.
85+ * Developers (maybe you) who debug a particular issue.
86+
87+ The first 3 log levels are for ops:
88+
89+ * `ERROR `: something that renders the driver -- or a part of it -- completely unusable. An action is
90+ required to fix it: bouncing the client, applying a patch, etc.
91+ * `WARN `: something that the driver can recover from automatically, but indicates a configuration or
92+ programming error that should be addressed. For example: the driver connected successfully, but
93+ one of the contact points in the configuration was malformed; the same prepared statement is being
94+ prepared multiple time by the application code.
95+ * `INFO `: something that is part of the normal operation of the driver, but might be useful to know
96+ for an operator. For example: the driver has initialized successfully and is ready to process
97+ queries; an optional dependency was detected in the classpath and activated an enhanced feature.
98+
99+ Do not log errors that are rethrown to the client (such as the error that you' re going to complete a
100+ request with). This is annoying for ops because they see a lot of stack traces that require no
101+ actual action on their part, because they' re already handled by application code.
102+
103+ The last 2 levels are for developers:
104+
105+ * `DEBUG `: anything that would be useful to understand what the driver is doing from a " black box"
106+ perspective, i. e. if all you have are the logs.
107+ * `TRACE `: same thing, but for events that happen very often, produce a lot of output, or should be
108+ irrelevant most of the time (this is a bit more subjective and left to your interpretation).
109+
110+ Logs statements start with a prefix that identifies its origin, for example:
111+
112+ * for components that are unique to the cluster instance, just the cluster name: `[c0]`.
113+ * for sessions, the cluster name + a generated unique identifier: `[c0| s0]`.
114+ * for channel pools, the session identifier + the address of the node: `[c0| s0| / 127.0 . 0.2 : 9042 ]`.
115+ * for channels, the identifier of the owner (session or control connection) + the Netty identifier,
116+ which indicates the local and remote ports:
117+ `[c0| s0| id: 0xf9ef0b15 , L : / 127.0 . 0.1 : 51482 - R : / 127.0 . 0.1 : 9042 ]`.
118+ * for request handlers, the session identifier, a unique identifier, and the index of the
119+ speculative execution: `[c0| s0| 1077199500 | 0 ]`.
120+
121+ Tests run with the configuration defined in `src/ test/ resources/ logback- test. xml`. The default level
122+ for driver classes is `WARN `, but you can override it with a system property: `- DdriverLevel = DEBUG `.
123+ A nice setup is to use `DEBUG ` when you run from your IDE , and keep the default for the command
124+ line.
125+
126+ When you add or review new code, take a moment to run the tests in `DEBUG` mode and check if the
127+ output looks good.
128+
74129## Coding style -- test code
75130
76131Static imports are permitted in a couple of places:
0 commit comments