Skip to content

Commit

Permalink
fix broken link and add logging example (FuelLabs#3767)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahschwartz authored Jan 12, 2023
1 parent e236d76 commit d9f6f8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ cargo run --bin forc -- --help

We welcome contributions to Sway!

Please see the [Contributing To Sway](https://fuellabs.github.io/sway/master/reference/contributing_to_sway.html) section of the Sway book for guidelines and instructions to help you get started.
Please see the [Contributing To Sway](https://fuellabs.github.io/sway/master/book/reference/contributing_to_sway.html) section of the Sway book for guidelines and instructions to help you get started.
11 changes: 11 additions & 0 deletions docs/book/src/basics/comments_and_logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ fn main() {

The `logging` library provides a generic `log` function that can be imported using `use std::logging::log` and used to log variables of any type. Each call to `log` appends a `receipt` to the list of receipts. There are two types of receipts that a `log` can generate: `Log` and `LogData`.

```sway
fn log_values(){
// Generates a Log receipt
log(42);
// Generates a LogData receipt
let string = "sway";
log(string);
}
```

### `Log` Receipt

The `Log` receipt is generated for _non-reference_ types, namely `bool`, `u8`, `u16`, `u32`, and `u64`. For example, logging an integer variable `x` that holds the value `42` using `log(x)` may generate the following receipt:
Expand Down

0 comments on commit d9f6f8a

Please sign in to comment.