github.com/lei006/gmqtt-broker@v0.0.1/plugins/bridge/CSVLog.md (about) 1 # CSVLog Plugin For HMQ 2 This is a bridge implementation for HMQ that allows messages to be logged to a CSV file at runtime. 3 4 It can be used for debugging/monitoring purposes, for integration with other systems/platforms, or as an audit trail of messages. 5 6 The plugin allows you to define 0, 1, or more filters which determine which messages get bridged. Where no filters are defined the plugin bridges every message. Where one or more filters exist, the plugin applies the filter/s and only brdiges messages that match the filter spec. 7 8 The plugin allows you provide a filename for the output file, and also supports three special filenames {LOG},{STDOUT}, and {NULL}. {LOG} results in messages being bridged to the log, {STDOUT} bridges them to Std out, and {NULL} simply skips and returns without an error. 9 10 ## Configuration 11 The configiration settings for CSVLog are defined by the struct csvBridgeConfig. 12 ``` 13 type csvBridgeConfig struct { 14 FileName string `json:"fileName"` 15 LogFileMaxSizeMB int64 `json:"logFileMaxSizeMB"` 16 LogFileMaxFiles int64 `json:"logFileMaxFiles"` 17 WriteIntervalSecs int64 `json:"writeIntervalSecs"` 18 CommandTopic string `json:"commandTopic"` 19 Filters []string `json:"filters"` 20 } 21 ``` 22 | Setting | Description | 23 | ----------- | ----------- | 24 | FileName | A complete filename for the output file, or {LOG} to send bridged messages to the log, {STDOUT} to send bridged messages to STDOUT, or {NULL} to not bridge anything at all | 25 | LogFileMaxSizeMB | The size in megabytes at which the log file is rotated | 26 | LogFileMaxFiles | The maximum number of rotated logfiles to retain before they're deleted | 27 | WriteIntervalSecs | The delay before flushing any pending writes to the file | 28 | CommandTopic | The name of a topic to which commands relating to CSVLog will be sent eg "bridge/CSVLOG/command" | 29 | Filters | An array of filter specifications which are used to determine which messages are bridged, if there are no filters specified the filter is assumed to be "#" which bridges everything. Filters are specified the same way that topic acls are described| 30 31 ## Filters 32 33 Filters use the same syntax as for ACL permissions. 34 35 So a filter can name a specific topic.. 36 37 "animals/cats" will bridge messages sent to the "animals/cats" topic. 38 39 A filter can use the + or # wildcards so 40 41 "animals/cats/+" will bridge messages sent to "animals/cats/breeds", "animals/cats/colours" but not "animals/cats/breeds/longhair" 42 43 "animals/cats/#" will bridge messages sent to "animals/cats/breeds", "animals/cats/colours", "animals/cats/breeds/longhair", etc 44 45 ## Commands 46 Currently two commands can be sent to the CSVLog bridge: 47 48 ROTATEFILE - Triggers an immediate rotation of the log file 49 50 REALOADCONFIG - Triggers a reload of the CSVLog config file