6 Logging, tracing, and debugging

 

This chapter covers

  • Using logging, tracing, and debugging in your web service
  • Understanding logging options in Rust
  • Using external crates to improve your logging experience
  • Using the tracing crate in your web service
  • Setting up a debugging environment for your Rust web service
  • Debugging a web service written in Rust

The first five chapters of the book covered implementing a web service in Rust, why and how to implement asynchronous concepts, and the splitting of our Rust code into modules and libraries. This alone helps to read and understand the code and makes future changes fast to implement. You also learned how to use the rigid nature of the compiler to help spot errors and improve your code.

This chapter covers the instrumentation of your web service. By this, we mean tracing information and diagnosing errors. Even during development, you most probably start to log information to the console to introspect HTTP calls or errors inside functions. This behavior, however, can be expanded and more streamlined. This is covered by logging and tracing your application.

6.1 Logging in your Rust application

6.1.1 Implementing logging in your web service

6.1.2 Logging incoming HTTP requests

6.1.3 Creating structured logs

6.2 Tracing in asynchronous applications

6.2.1 Introducing the Tracing crate

6.2.2 Integrating tracing in our application

6.3 Debugging Rust applications

6.3.1 Using GDB on the command line

6.3.2 Debugging our web service with LLDB

6.3.3 Using Visual Studio Code and LLDB

Summary