Skip to content

Commit

Permalink
Add details about building with logs to project setup (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch authored Oct 9, 2022
1 parent e5c8d81 commit b7a4854
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion docs/tutorials/create-a-project.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ Configuring the `release` profile to optimize the contract build is critical.
Soroban contracts have a maximum size of 256KB. Rust programs, even small ones,
without these configurations almost always exceed this size.

Add the following to your `Cargo.toml`.
Add the following to your `Cargo.toml` and use the `release` profile when
building.

```toml
[profile.release]
Expand All @@ -84,6 +85,26 @@ codegen-units = 1
lto = true
```

## Configure the `release-with-logs` Profile

Configuring a `release-with-logs` profile can be useful for if you need to build
a `.wasm` that has logs enabled for printing debug logs when using the
[`soroban-cli`]. Note that this is not necessary to access debug logs in tests
or to use a step-through-debugger.

Add the following to your `Cargo.toml` and use the `release-with-logs` profile
when you need logs.

```toml
[profile.release-with-logs]
inherits = "release"
debug-assertions = true
```

See the [logging example] for more information about how to log.

[logging example]: ../examples/logging.mdx

## Wrapping it Up

The steps below should produce a `Cargo.toml` that looks like so.
Expand All @@ -110,7 +131,12 @@ debug-assertions = false
panic = "abort"
codegen-units = 1
lto = true

[profile.release-with-logs]
inherits = "release"
debug-assertions = true
```

[Rust unit tests]: https://doc.rust-lang.org/rust-by-example/testing/unit_testing.html
[Rust integration tests]: https://doc.rust-lang.org/rust-by-example/testing/integration_testing.html
[`soroban-cli`]: ../getting-started/setup#install-the-soroban-cli

0 comments on commit b7a4854

Please sign in to comment.