Skip to content

Commit

Permalink
Merge pull request #122 from iotaledger/chore/upgrade-logger
Browse files Browse the repository at this point in the history
Upgrade logger
  • Loading branch information
muXxer authored Dec 15, 2023
2 parents 3849289 + 4fc10df commit 60c70c5
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 149 deletions.
2 changes: 1 addition & 1 deletion components/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var (
Name = "inx-mqtt"

// Version of the app.
Version = "2.0.0-alpha.7"
Version = "2.0.0-alpha.8"
)

func App() *app.App {
Expand Down
2 changes: 1 addition & 1 deletion components/mqtt/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func provide(c *dig.Container) error {
}

return mqtt.NewServer(
Component.Logger(),
Component.Logger,
deps.NodeBridge,
broker,
deps.ShutdownHandler,
Expand Down
6 changes: 3 additions & 3 deletions components/mqtt/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ type ParametersMQTT struct {
TopicsCleanupThresholdRatio float32 `default:"1.0" usage:"the ratio of subscribed topics to deleted topics that trigger a garbage collection of the subscription manager"`
}

MaximumClientWritesPending int `default:"0" usage:"the maximum number of pending message writes for a client"`
ClientWriteBufferSize int `default:"0" usage:"the size of the client write buffer"`
ClientReadBufferSize int `default:"0" usage:"the size of the client read buffer"`
MaximumClientWritesPending int `default:"8192" usage:"the maximum number of pending message writes for a client"`
ClientWriteBufferSize int `default:"2048" usage:"the size of the client write buffer"`
ClientReadBufferSize int `default:"2048" usage:"the size of the client read buffer"`
}

var ParamsMQTT = &ParametersMQTT{
Expand Down
2 changes: 1 addition & 1 deletion components/prometheus/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func run() error {
//nolint:contextcheck // false positive
err := deps.PrometheusEcho.Shutdown(shutdownCtx)
if err != nil {
Component.LogWarn(err)
Component.LogWarn(err.Error())
}

Component.LogInfo("Stopping Prometheus exporter ... done")
Expand Down
18 changes: 6 additions & 12 deletions config_defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@
}
},
"logger": {
"name": "",
"level": "info",
"disableCaller": true,
"disableStacktrace": false,
"stacktraceLevel": "panic",
"encoding": "console",
"encodingConfig": {
"timeEncoder": "rfc3339"
},
"timeFormat": "rfc3339",
"outputPaths": [
"stdout"
],
"disableEvents": true
]
},
"inx": {
"address": "localhost:9029",
Expand Down Expand Up @@ -60,9 +54,9 @@
"topicsCleanupThresholdCount": 10000,
"topicsCleanupThresholdRatio": 1
},
"maximumClientWritesPending": 0,
"clientWriteBufferSize": 0,
"clientReadBufferSize": 0
"maximumClientWritesPending": 8192,
"clientWriteBufferSize": 2048,
"clientReadBufferSize": 2048
},
"profiling": {
"enabled": false,
Expand Down
46 changes: 15 additions & 31 deletions configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,40 +71,24 @@ Example:

## <a id="logger"></a> 2. Logger

| Name | Description | Type | Default value |
| ---------------------------------------- | --------------------------------------------------------------------------- | ------- | ------------- |
| level | The minimum enabled logging level | string | "info" |
| disableCaller | Stops annotating logs with the calling function's file name and line number | boolean | true |
| disableStacktrace | Disables automatic stacktrace capturing | boolean | false |
| stacktraceLevel | The level stacktraces are captured and above | string | "panic" |
| encoding | The logger's encoding (options: "json", "console") | string | "console" |
| [encodingConfig](#logger_encodingconfig) | Configuration for encodingConfig | object | |
| outputPaths | A list of URLs, file paths or stdout/stderr to write logging output to | array | stdout |
| disableEvents | Prevents log messages from being raced as events | boolean | true |

### <a id="logger_encodingconfig"></a> EncodingConfig

| Name | Description | Type | Default value |
| ----------- | ---------------------------------------------------------------------------------------------------------- | ------ | ------------- |
| timeEncoder | Sets the logger's timestamp encoding. (options: "nanos", "millis", "iso8601", "rfc3339" and "rfc3339nano") | string | "rfc3339" |
| Name | Description | Type | Default value |
| ----------- | -------------------------------------------------------------------------------------------------------------- | ------ | ------------- |
| name | The optional name of the logger instance. All log messages are prefixed with that name. | string | "" |
| level | The minimum enabled logging level | string | "info" |
| timeFormat | Sets the logger's timestamp format. (options: "rfc3339", "rfc3339nano", "datetime", "timeonly", and "iso8601") | string | "rfc3339" |
| outputPaths | A list of file paths or stdout/stderr to write logging output to | array | stdout |

Example:

```json
{
"logger": {
"name": "",
"level": "info",
"disableCaller": true,
"disableStacktrace": false,
"stacktraceLevel": "panic",
"encoding": "console",
"encodingConfig": {
"timeEncoder": "rfc3339"
},
"timeFormat": "rfc3339",
"outputPaths": [
"stdout"
],
"disableEvents": true
]
}
}
```
Expand Down Expand Up @@ -139,9 +123,9 @@ Example:
| publicTopics | The MQTT topics which can be subscribed to without authorization. Wildcards using \* are allowed | array | commitments/\*<br/>blocks/\*<br/>transactions/\*<br/>block-metadata/\*<br/>outputs/\* |
| protectedTopics | The MQTT topics which only can be subscribed to with valid authorization. Wildcards using \* are allowed | array | |
| [subscriptions](#mqtt_subscriptions) | Configuration for subscriptions | object | |
| maximumClientWritesPending | The maximum number of pending message writes for a client | int | 0 |
| clientWriteBufferSize | The size of the client write buffer | int | 0 |
| clientReadBufferSize | The size of the client read buffer | int | 0 |
| maximumClientWritesPending | The maximum number of pending message writes for a client | int | 8192 |
| clientWriteBufferSize | The size of the client write buffer | int | 2048 |
| clientReadBufferSize | The size of the client read buffer | int | 2048 |

### <a id="mqtt_websocket"></a> Websocket

Expand Down Expand Up @@ -218,9 +202,9 @@ Example:
"topicsCleanupThresholdCount": 10000,
"topicsCleanupThresholdRatio": 1
},
"maximumClientWritesPending": 0,
"clientWriteBufferSize": 0,
"clientReadBufferSize": 0
"maximumClientWritesPending": 8192,
"clientWriteBufferSize": 2048,
"clientReadBufferSize": 2048
}
}
```
Expand Down
26 changes: 12 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ module github.com/iotaledger/inx-mqtt
go 1.21

require (
github.com/iotaledger/hive.go/app v0.0.0-20231211160503-bcd86a4d1ece
github.com/iotaledger/hive.go/ierrors v0.0.0-20231211160503-bcd86a4d1ece
github.com/iotaledger/hive.go/lo v0.0.0-20231211160503-bcd86a4d1ece
github.com/iotaledger/hive.go/logger v0.0.0-20231211160503-bcd86a4d1ece
github.com/iotaledger/hive.go/runtime v0.0.0-20231211160503-bcd86a4d1ece
github.com/iotaledger/hive.go/app v0.0.0-20231214121634-8b23c68d408d
github.com/iotaledger/hive.go/ierrors v0.0.0-20231214121634-8b23c68d408d
github.com/iotaledger/hive.go/lo v0.0.0-20231214121634-8b23c68d408d
github.com/iotaledger/hive.go/log v0.0.0-20231214121634-8b23c68d408d
github.com/iotaledger/hive.go/runtime v0.0.0-20231214121634-8b23c68d408d
github.com/iotaledger/hive.go/web v0.0.0-20231211160503-bcd86a4d1ece
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231206124511-b78dc962031f
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231214130218-3be90355a276
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231206124145-f773dfe3927e
github.com/iotaledger/iota.go/v4 v4.0.0-20231206123921-2af411eef0b5
github.com/labstack/echo/v4 v4.11.3
Expand Down Expand Up @@ -43,12 +43,12 @@ require (
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/iancoleman/orderedmap v0.3.0 // indirect
github.com/iotaledger/hive.go/constraints v0.0.0-20231211160503-bcd86a4d1ece // indirect
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231207181026-f482ac139305 // indirect
github.com/iotaledger/hive.go/crypto v0.0.0-20231211160503-bcd86a4d1ece // indirect
github.com/iotaledger/hive.go/ds v0.0.0-20231211160503-bcd86a4d1ece // indirect
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231207181026-f482ac139305 // indirect
github.com/iotaledger/hive.go/stringify v0.0.0-20231211160503-bcd86a4d1ece // indirect
github.com/iotaledger/hive.go/constraints v0.0.0-20231214121634-8b23c68d408d // indirect
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231214121634-8b23c68d408d // indirect
github.com/iotaledger/hive.go/crypto v0.0.0-20231214121634-8b23c68d408d // indirect
github.com/iotaledger/hive.go/ds v0.0.0-20231214121634-8b23c68d408d // indirect
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231214121634-8b23c68d408d // indirect
github.com/iotaledger/hive.go/stringify v0.0.0-20231214121634-8b23c68d408d // indirect
github.com/knadh/koanf v1.5.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/labstack/gommon v0.4.1 // indirect
Expand All @@ -74,8 +74,6 @@ require (
github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sync v0.5.0 // indirect
Expand Down
Loading

0 comments on commit 60c70c5

Please sign in to comment.