Skip to content

Commit cb02265

Browse files
committed
update logging related information
1 parent 5c8294c commit cb02265

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

documents/FAQ.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616
If you are just getting started make sure you [install this sdk](https://github.com/aws/aws-iot-device-sdk-python-v2#installation) and then build and run the [basic PubSub](https://github.com/aws/aws-iot-device-sdk-python-v2/tree/main/samples#pubsub)
1717

1818
### How do I enable logging?
19+
To enable logging you must import `io` from `awscrt` and initialize it with `init_logging`.
1920

21+
`LogLevel` can be set to `Fatal`, `Error`, `Warn`, `Info`, `Debug`, or `Trace`. `stderr` and `stdout` can be used to print logs while any other string will be assumed to be a file path.
2022
``` python
23+
from awscrt import io
24+
# This sets the logger to print any Error level logs to stderr
2125
io.init_logging(io.LogLevel.Error, 'stderr')
2226
```
2327
You can also enable [CloudWatch logging](https://docs.aws.amazon.com/iot/latest/developerguide/cloud-watch-logs.html) for IoT which will provide you with additional information that is not available on the client side sdk.

samples/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ This directory contains sample applications for [aws-iot-device-sdk-python-v2](.
66
* [MQTT5 Client Samples](#mqtt5-client-samples)
77
* [Service Client Samples](#service-client-samples)
88
* [Greengrass Samples](#greengrass-samples)
9-
* [Build Instructions](#build-instructions)
9+
* [Instructions](#instructions)
1010
* [Sample Help](#sample-help)
11-
* [Enable Logging in Samples](#enable-logging-in-samples)
11+
* [Enable Logging](#enable-logging)
1212

1313

1414
## Samples
@@ -39,9 +39,9 @@ This directory contains sample applications for [aws-iot-device-sdk-python-v2](.
3939
| [Greengrass Discovery](./greengrass//basic_discovery.md) | Discover and connect to a local Greengrass core. |
4040
| [Greengrass IPC](./greengrass//ipc_greengrass.md) | Demonstrates Inter-Process Communication (IPC) with Greengrass components. |
4141

42-
### Build Instructions
42+
### Instructions
4343

44-
First, install the `aws-iot-devices-sdk-python-v2` with following the [Installation Instructions](../README.md#Installation).
44+
First, install `aws-iot-devices-sdk-python-v2`. Installation instructions for the SDK are [Provided Here](../README.md#Installation).
4545

4646
Each sample's README contains prerequisites, arguments, and detailed instructions. For example, the [MQTT5 X509 Sample README](./mqtt/mqtt5_x509.md) is `mqtt5_x509.md` and the sample can be run with the following command:
4747

@@ -80,6 +80,6 @@ optional arguments:
8080

8181
The sample will not run without the required arguments and will notify you of missing arguments.
8282

83-
### Enable logging in samples
83+
### Enable Logging
8484

85-
To enable logging in the samples, you can follow the instructions provided in the [FAQ](../documents/FAQ.md) related to [enabling logs](../documents/FAQ.md#how-do-i-enable-logging).
85+
Instructions to enable logging are available in the [FAQ](../documents/FAQ.md) under [How do I enable logging](../documents/FAQ.md#how-do-i-enable-logging).

samples/mqtt/mqtt5_x509.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0.
33

44
from awsiot import mqtt5_client_builder
5-
from awscrt import mqtt5
5+
from awscrt import mqtt5, io
66
import threading, time
77

88
# --------------------------------- ARGUMENT PARSING -----------------------------------------
@@ -38,7 +38,7 @@
3838
# args contains all the parsed commandline arguments used by the sample
3939
args = parser.parse_args()
4040
# --------------------------------- ARGUMENT PARSING END -----------------------------------------
41-
41+
io.init_logging(io.LogLevel.Debug, 'stdout')
4242
TIMEOUT = 100
4343
message_count = args.input_count
4444
message_topic = args.input_topic

0 commit comments

Comments
 (0)