thin-edge / thin-edge.io

The open edge framework for lightweight IoT devices
https://thin-edge.io
Apache License 2.0
218 stars 54 forks source link

Add --debug flag to tedge CLI framework #2089

Open PradeepKiruvale opened 1 year ago

PradeepKiruvale commented 1 year ago

Is your feature improvement request related to a problem? Please describe.

The tedge CLI framework is used in thin-edge devices to create/update configs, create certificates, and connect to the cloud. It's also used to subscribe and publish MQTT messages. If something goes wrong while the CLI framework is being used, there is no way to debug, it can’t print more information about what is happening.

Describe the solution you'd like

Enable the debug feature to tedge the CLI framework,

Describe alternatives you've considered

Additional context

reubenmiller commented 10 months ago

For those who are interested, you can enable detailed logging by setting the RUST_LOG variable before calling the command, e.g.

sudo RUST_LOG=debug tedge connect c8y
The system config file '/etc/tedge/system.toml' doesn't exist. Use '/bin/systemctl' as a service manager.

2023-11-07T09:54:13.508234073Z DEBUG tedge_config::tedge_config_cli::tedge_config_repository: Loading configuration from "/etc/tedge/tedge.toml"
Detected mosquitto version >= 2.0.0
Checking if systemd is available.

Checking if configuration for requested bridge already exists.

Validating the bridge certificates.

Creating the device in Cumulocity cloud.

2023-11-07T09:54:13.678628567Z DEBUG rustls::client::hs: No cached session for DnsName("example.c8y.io")
2023-11-07T09:54:13.678969297Z DEBUG rustls::client::hs: Not resuming any session
2023-11-07T09:54:13.719520593Z DEBUG rustls::client::hs: Using ciphersuite TLS13_AES_256_GCM_SHA384
2023-11-07T09:54:13.719630333Z DEBUG rustls::client::tls13: Not resuming
2023-11-07T09:54:13.721003465Z DEBUG rustls::client::tls13: TLS1.3 encrypted extensions: [Unknown(UnknownExtension { typ: EllipticCurves, payload: 0014001d001700180019001e01000101010201030104 })]
2023-11-07T09:54:13.721122997Z DEBUG rustls::client::hs: ALPN protocol is None
2023-11-07T09:54:13.721198414Z DEBUG rustls::client::tls13: Got CertificateRequest CertificateRequestPayloadTLS13 { context: , extensions: [SignatureAlgorithms([ECDSA_NISTP256_SHA256, ECDSA_NISTP384_SHA384, ECDSA_NISTP521_SHA512, RSA_PSS_SHA256, RSA_PSS_SHA384, RSA_PSS_SHA512, Unknown(2057), Unknown(2058), Unknown(2059), RSA_PKCS1_SHA256, RSA_PKCS1_SHA384, RSA_PKCS1_SHA512, ECDSA_SHA1_Legacy, RSA_PKCS1_SHA1]), Unknown(UnknownExtension { typ: SignatureAlgorithmsCert, payload: 001c0403050306030804080508060809080a080b04010501060102030201 })] }
2023-11-07T09:54:13.721297216Z DEBUG rustls::client::common: Attempting client auth
2023-11-07T09:54:13.820443907Z DEBUG rumqttc::state: Subscribe. Topics = [Filter = s/e, Qos = AtLeastOnce], Pkid = 1
2023-11-07T09:54:13.844879445Z DEBUG rumqttc::state: Publish. Topic = s/us, Pkid = 2, Payload Size = 27