Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The Complete Rust Programming Reference Guide

You're reading from   The Complete Rust Programming Reference Guide Design, develop, and deploy effective software systems using the advanced constructs of Rust

Arrow left icon
Product type Course
Published in May 2019
Publisher Packt
ISBN-13 9781838828103
Length 698 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Authors (3):
Arrow left icon
Vesa Kaihlavirta Vesa Kaihlavirta
Author Profile Icon Vesa Kaihlavirta
Vesa Kaihlavirta
Rahul Sharma Rahul Sharma
Author Profile Icon Rahul Sharma
Rahul Sharma
Claus Matzinger Claus Matzinger
Author Profile Icon Claus Matzinger
Claus Matzinger
Arrow right icon
View More author details
Toc

Table of Contents (29) Chapters Close

Title Page
Copyright
About Packt
Contributors
Preface
1. Getting Started with Rust FREE CHAPTER 2. Managing Projects with Cargo 3. Tests, Documentation, and Benchmarks 4. Types, Generics, and Traits 5. Memory Management and Safety 6. Error Handling 7. Advanced Concepts 8. Concurrency 9. Metaprogramming with Macros 10. Unsafe Rust and Foreign Function Interfaces 11. Logging 12. Network Programming in Rust 13. Building Web Applications with Rust 14. Lists, Lists, and More Lists 15. Robust Trees 16. Exploring Maps and Sets 17. Collections in Rust 18. Algorithm Evaluation 19. Ordering Things 20. Finding Stuff 21. Random and Combinatorial 22. Algorithms of the Standard Library 1. Other Books You May Enjoy Index

Logging in Rust


Rust has quite a few flexible and extensive logging solutions. Like popular logging frameworks in other languages, the logging ecosystem here is split into two parts:

  • Logging facade: This part is implemented by the log crate and provides an implementation agnostic logging API. While other frameworks implement logging APIs as functions or methods on some object, the log crate provides us with macro-based logging APIs, which are categorized by log levels to log events to a configured log output.
  • Logging implementations: These are community developed crates that provide actual logging implementation in terms of where the output goes and how it happens. There are many such crates, such asenv_logger,simple_logger,log4rs, and fern. We'll visit a couple of them in a moment. Crates that come under this category are meant to be used only by binary crates, that is, executables.

This separation of concerns between the logging API and the underlying mechanism by which logs go to an output...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image