| 1 |
### Logging conventions |
| 2 |
|
| 3 |
A log message (the string/format passed to `Info`, `Error`, `Debug` etc, as well as their `Sprintf` counterparts) should |
| 4 |
be a descriptive message about the event and may contain specific identifying characteristics. Regardless of the |
| 5 |
level of detail in the message identifying characteristics should always be included via `WithField`, `WithFields` or |
| 6 |
`WithError` |
| 7 |
|
| 8 |
If an error is being logged use `l.WithError(err)` so that there is better discoverability about the event as well |
| 9 |
as the specific error condition. |
| 10 |
|
| 11 |
#### Common fields |
| 12 |
|
| 13 |
- `cert` - a `cert.NebulaCertificate` object, do not `.String()` this manually, `logrus` will marshal objects properly |
| 14 |
for the formatter it is using. |
| 15 |
- `fingerprint` - a single `NebeulaCertificate` hex encoded fingerprint |
| 16 |
- `fingerprints` - an array of `NebulaCertificate` hex encoded fingerprints |
| 17 |
- `fwPacket` - a FirewallPacket object |
| 18 |
- `handshake` - an object containing: |
| 19 |
- `stage` - the current stage counter |
| 20 |
- `style` - noise handshake style `ix_psk0`, `xx`, etc |
| 21 |
- `header` - a nebula header object |
| 22 |
- `udpAddr` - a `net.UDPAddr` object |
| 23 |
- `udpIp` - a udp ip address |
| 24 |
- `vpnIp` - vpn ip of the host (remote or local) |
| 25 |
- `relay` - the vpnIp of the relay host that is or should be handling the relay packet |
| 26 |
- `relayFrom` - The vpnIp of the initial sender of the relayed packet |
| 27 |
- `relayTo` - The vpnIp of the final destination of a relayed packet |
| 28 |
|
| 29 |
#### Example: |
| 30 |
|
| 31 |
``` |
| 32 |
l.WithError(err). |
| 33 |
WithField("vpnIp", IntIp(hostinfo.hostId)). |
| 34 |
WithField("udpAddr", addr). |
| 35 |
WithField("handshake", m{"stage": 1, "style": "ix"}). |
| 36 |
Info("Invalid certificate from host") |
| 37 |
``` |