Skip to content

Commit 96c228b

Browse files
committed
Build
1 parent 5f36a80 commit 96c228b

File tree

9 files changed

+148
-150
lines changed

9 files changed

+148
-150
lines changed

chapter_1.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ <h1 class="menu-title">Logging with Bevy</h1>
176176
<h1 id="println-and-eprintln"><a class="header" href="#println-and-eprintln">Println! and eprintln</a></h1>
177177
<h2 id="println"><a class="header" href="#println">Println!</a></h2>
178178
<p>The first tool which you may reach for when you experience unexpected behaviour is <code>println!</code>.
179-
<code>println!</code> can be used as the name suggests to print values at key points of your program where your issue might lie.</p>
179+
<code>println!</code> can be used, as the name suggests, to print values at key points of your program where your issue might lie.</p>
180180
<p>However</p>
181181
<ul>
182182
<li>Typing, or more likely copying and pasting <code>println!</code>'s everywhere gets quite tedious.</li>
183-
<li>Each <code>println!</code> should in most cases have some marking string that lets you know which one triggered,otherwise you have to do additional searching.</li>
184-
<li>At some point these <code>println!</code>'s need to removed or they will block up the logging.</li>
183+
<li>Each <code>println!</code> should, in most cases, have some marking string that lets you know which one triggered, otherwise you have to do additional searching.</li>
184+
<li>At some point, these <code>println!</code>'s need to be removed, or they will block up the logging.</li>
185185
</ul>
186186

187187
</main>

chapter_2.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ <h1 class="menu-title">Logging with Bevy</h1>
173173

174174
<div id="content" class="content">
175175
<main>
176-
<h1 id="redirceting-output-to-a-file"><a class="header" href="#redirceting-output-to-a-file">Redirceting output to a file</a></h1>
177-
<p>You may already know <code>stdout</code> can be redirected to file using the <code>&gt;</code> operator.
178-
When you have lots of logging the screen can get fill quickly so redirecting can help you
179-
manage all that information</p>
176+
<h1 id="redirecting-output-to-a-file"><a class="header" href="#redirecting-output-to-a-file">Redirecting output to a file</a></h1>
177+
<p>You may already know <code>stdout</code> can be redirected to a file using the <code>&gt;</code> operator.
178+
When there is a lot of logging, the screen can fill quickly, so redirecting can help
179+
you manage all that information.</p>
180180
<p>An example below.</p>
181181
<p><code>Cargo run &gt; output.txt</code></p>
182182
<p>This gives you two major benefits</p>
@@ -185,7 +185,7 @@ <h1 id="redirceting-output-to-a-file"><a class="header" href="#redirceting-outpu
185185
<li>you can use a diff program <sup class="footnote-reference"><a href="#note">1</a></sup> to compare outputs for different executions</li>
186186
</ul>
187187
<div class="footnote-definition" id="note"><sup class="footnote-definition-label">1</sup>
188-
<p>Lots of text editors and IDE's have a built in diff editor, Alternitavely I use Delta</p>
188+
<p>Lots of text editors and IDE's have a built-in diff editor. Alternatively, I use Delta.</p>
189189
</div>
190190

191191
</main>

chapter_3.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ <h1 id="dbg-macro"><a class="header" href="#dbg-macro">Dbg macro</a></h1>
181181
// ^-- prints: [src/main.rs:2:9] a * 2 = 4
182182
assert_eq!(b, 5);</code></pre>
183183
<p>Notice that the file path and line numbers are printed.
184-
This metadata is generated at compile time so will keep up with changes made in your program.</p>
185-
<p>This means it less essential to make your <code>dbg</code> statements unique.</p>
186-
<p>However there are still some disadvantages (same as <code>println!</code>)</p>
184+
This metadata is generated at compile time, so it will keep up with changes made in your program.</p>
185+
<p>This means it is less essential to make your <code>dbg</code> statements unique.</p>
186+
<p>However, there are still some disadvantages (same as <code>println!</code>)</p>
187187
<ul>
188188
<li>Typing or more likely copying and pasting <code>dbg!</code>'s everywhere gets quite tedious</li>
189189
<li>At some point these <code>dbg!</code>'s need to removed or they will block up the logging</li>

chapter_4.html

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ <h1 class="menu-title">Logging with Bevy</h1>
175175
<main>
176176
<h1 id="the-log-plugin"><a class="header" href="#the-log-plugin">The log Plugin</a></h1>
177177
<p>One of Bevy's default plugins is the log plugin.</p>
178-
<p>Lets configure the plugin then explain as we see what happens</p>
178+
<p>Let's configure the plugin, then explain as we see what happens</p>
179179
<pre><code class="language-rust">fn main() {
180180
App::new()
181181
.add_plugins(DefaultPlugins.set(LogPlugin {
@@ -187,8 +187,7 @@ <h1 id="the-log-plugin"><a class="header" href="#the-log-plugin">The log Plugin<
187187
.run();
188188
}
189189

190-
</code></pre>
191-
<p>The rest of the code of an example application.</p>
190+
// The rest of the code...</code></pre>
192191
<p>Code can also be found <a href="https://github.com/bevy-logging/test_spiral">here.</a></p>
193192
<pre><code class="language-rust">use bevy::{log::LogPlugin, prelude::*};
194193
use rand::prelude::*;
@@ -287,11 +286,11 @@ <h1 id="the-log-plugin"><a class="header" href="#the-log-plugin">The log Plugin<
287286
2024-10-19T21:46:13.389895Z TRACE wgpu_core::resource: Destroy raw Buffer (dropped) "Mesh Index Buffer"
288287

289288
</code></pre>
290-
<p>The console is absolutly flooded with debug messages from the bevy engine itself along with its dependencies.
291-
Libraries use a similar logging scheme to what is about to be shown below the idea is that you can filter out the irrelevant logs.
292-
In order to start filtering we need to learn about levels and the Env filter.</p>
289+
<p>The console is absolutely flooded with debug messages from the Bevy engine itself, along with its dependencies.
290+
Libraries use a similar logging scheme to what is about to be shown below. The idea is that you can filter out the irrelevant logs.
291+
In order to start filtering, we need to learn about levels and the Env filter.</p>
293292
<h2 id="log-levels"><a class="header" href="#log-levels">Log Levels</a></h2>
294-
<p>Tracing (Which the default Log plugin used for most Bevy Supported platforms with the major exceptions of the web and mobile) has the below log levels from highest (most detailed) to lowest (most important)</p>
293+
<p>Tracing (The default Log plugin used for most Bevy Supported platforms with the major exceptions of the web and mobile) has the below log levels from highest (most detailed) to lowest (most important)</p>
295294
<ul>
296295
<li><code>Trace</code> (Not printed by default)</li>
297296
<li><code>Debug</code> (Not printed by default)</li>
@@ -300,17 +299,17 @@ <h2 id="log-levels"><a class="header" href="#log-levels">Log Levels</a></h2>
300299
<li><code>Error</code></li>
301300
<li><code>None</code> (you turned off logging)</li>
302301
</ul>
303-
<p>Its up to you what these mean exactly but here is how I use them in Bevy.</p>
302+
<p>It's up to you what these mean exactly, but here is how I use them in Bevy.</p>
304303
<ul>
305304
<li><code>Trace</code> details inside a loop</li>
306305
<li><code>Debug</code> start or end of loops</li>
307-
<li><code>Info</code> usually what I am working on currently I then set to either debug or trace. I also use this for information
306+
<li><code>Info</code> usually what I am working on currently, I then set it to either debug or trace. I also use this for information
308307
I want to display but haven't built the UI for yet</li>
309308
<li><code>Warn</code> I never use</li>
310309
<li><code>Error</code> let else fail when I don't expect it to</li>
311310
</ul>
312-
<p>Lower levels are more important, higher levels (by convention not enforcement!) are more verbose.</p>
313-
<p>For example at the default level <code>Info</code> the levels below <code>Warn</code> and <code>Error</code> will also print.</p>
311+
<p>Lower levels are more important, while higher levels (by convention, not enforcement!) are more verbose.</p>
312+
<p>For example, at the default level <code>Info</code> the levels below <code>Warn</code> and <code>Error</code> will also print.</p>
314313
<p>Extract from the Tracing library</p>
315314
<pre><code class="language-rust">use tracing_core::Level;
316315

@@ -322,7 +321,7 @@ <h2 id="env-filter"><a class="header" href="#env-filter">Env Filter</a></h2>
322321
<p>An env filter is used to put specific filters per target, span and fields. For now just equate targets with modules.</p>
323322
<p>Spans will be discussed later.</p>
324323
<p>I have not needed fields, until I use them or someone else supplies an example fields are an excercise for the reader.</p>
325-
<p>To start with lets put a global env filter set all to warn, this can give you useful messages such as a uinode without an appopriate parent node</p>
324+
<p>To start with let's put a global env filter set all to warn, this can give you useful messages such as a UI-node without an appropriate parent node</p>
326325
<pre><code class="language-rust">fn main() {
327326
App::new()
328327
.add_plugins(DefaultPlugins.set(LogPlugin {
@@ -343,11 +342,11 @@ <h2 id="env-filter"><a class="header" href="#env-filter">Env Filter</a></h2>
343342
2024-10-19T22:03:13.952167Z WARN wgpu_hal::gles::egl: EGL says it can present to the window but not natively
344343
</code></pre>
345344
<h3 id="the-level-field"><a class="header" href="#the-level-field">The level field</a></h3>
346-
<p>The level field in the log plugin is a quick way to globally set all logs.
345+
<p>The level field in the log plugin is a quick way to set all logs globally.
347346
A major use case is having release and debug modes with different log levels.</p>
348347
<h3 id="adding-our-own-logging"><a class="header" href="#adding-our-own-logging">Adding our own logging</a></h3>
349-
<p>Ok so lets add in our own startup warning message, warning because only they and errors will show.
350-
We can print a warn message using Tracings supplied macros</p>
348+
<p>Ok, so let's add in our own startup warning message, warning because only they and errors will show.
349+
We can print a <code>Warn</code> message using Tracing's supplied macros</p>
351350
<pre><code class="language-rust">fn setup(
352351
mut commands: Commands,
353352
mut meshes: ResMut&lt;Assets&lt;Mesh&gt;&gt;,
@@ -371,10 +370,10 @@ <h3 id="adding-our-own-logging"><a class="header" href="#adding-our-own-logging"
371370
2024-10-19T22:06:52.007886Z WARN test_spiral: Hello Log
372371

373372
</code></pre>
374-
<p>Great we can put a message there, but its not really a warning we can move it to the info level.</p>
373+
<p>Great. We can put a message there, but it's not really a warning, so we can move it to the info level.</p>
375374
<p>We use Tracing's <code>info!</code> macro</p>
376375
<p><code>info!("Hello Log")</code></p>
377-
<p>Now lets run</p>
376+
<p>Now let's run</p>
378377
<pre><code>
379378
Running `target/debug/test_spiral`
380379
2024-10-19T22:08:28.501325Z WARN wgpu_hal::vulkan::instance: InstanceFlags::VALIDATION requested, but unable to find layer: VK_LAYER_KHRONOS_validation
@@ -384,18 +383,18 @@ <h3 id="adding-our-own-logging"><a class="header" href="#adding-our-own-logging"
384383
2024-10-19T22:08:28.518035Z WARN wgpu_hal::gles::egl: No config found!
385384
2024-10-19T22:08:28.518049Z WARN wgpu_hal::gles::egl: EGL says it can present to the window but not natively
386385
</code></pre>
387-
<p>Perhaps unsurprisingly The message did not appear as it is higher level then warning.
388-
Therefore our settings have declared this too verbose.</p>
386+
<p>Perhaps unsurprisingly, The message did not appear as it is at a higher level than <code>warning</code>.
387+
Therefore, our settings have declared this to be too verbose.</p>
389388
<h3 id="higher-level-logging-for-our-application"><a class="header" href="#higher-level-logging-for-our-application">Higher level logging for our application</a></h3>
390-
<p>First lets add the depenencies</p>
389+
<p>First, let's add the depenencies</p>
391390
<p><code>cargo add tracing</code></p>
392391
<p><code>cargo add tracing-subscriber</code></p>
393-
<p>In order to show our applications logging we need to change the env filter to show our applications at <code>info</code> level or above.</p>
392+
<p>In order to show our applications logging, we need to change the env filter to show our applications at the <code>info</code> level or above.</p>
394393
<p>The syntax introduced will be to change targets</p>
395394
<p><code>cratename::modulename</code></p>
396395
<p>I called my example crate test_spiral</p>
397-
<p>So the target we supply to the env filter will be <code>test_spiral</code> there is no module name, therfore it is left blank.</p>
398-
<p>Env filters are comma seperated so <code>warn,test_spiral=info</code> will mean "run <code>warn</code> level for as normal, for module test_spiral <code>info</code>"</p>
396+
<p>So, the target we supply to the env filter will be <code>test_spiral</code>. Since there is no module name, it is left blank.</p>
397+
<p>Env filters are comma separated so <code>warn,test_spiral=info</code> will mean "run <code>warn</code> level for as normal, for module test_spiral <code>info</code>"</p>
399398
<pre><code class="language-rust">fn main() {
400399
App::new()
401400
//Disable the defaults
@@ -407,7 +406,7 @@ <h3 id="higher-level-logging-for-our-application"><a class="header" href="#highe
407406
.add_systems(Startup, setup)
408407
.run();
409408
}</code></pre>
410-
<p>Lets run</p>
409+
<p>Let's run</p>
411410
<pre><code> Running `target/debug/test_spiral`
412411
2024-10-19T22:12:21.298476Z WARN wgpu_hal::vulkan::instance: InstanceFlags::VALIDATION requested, but unable to find layer: VK_LAYER_KHRONOS_validation
413412
2024-10-19T22:12:21.307716Z WARN wgpu_hal::vulkan::instance: GENERAL [Loader Message (0x0)]
@@ -419,7 +418,7 @@ <h3 id="higher-level-logging-for-our-application"><a class="header" href="#highe
419418
</code></pre>
420419
<p>Excellent</p>
421420
<h3 id="module"><a class="header" href="#module">Module</a></h3>
422-
<p>We are going to make a second module we will keep it in the same file for simplicity but it will work for seperate files</p>
421+
<p>We are going to make a second module we will keep it in the same file for simplicity but it will work for separate files</p>
423422
<pre><code class="language-rust">use bevy::{log::LogPlugin, prelude::*};
424423
use rand::prelude::*;
425424
use tracing::Level;
@@ -504,8 +503,8 @@ <h3 id="module"><a class="header" href="#module">Module</a></h3>
504503
}
505504
}
506505
}</code></pre>
507-
<p><code>?i</code> just means use debug of that variable to print, otherwise you can use the macros same way as <code>println!</code>
508-
lets first change the log level for our application to be at <code>trace</code></p>
506+
<p><code>?i</code> just means use debug of that variable to print. Otherwise you can use the macros the same way as <code>println!</code></p>
507+
<p>Let's first change the log level for our application to be at <code>trace</code></p>
509508
<pre><code class="language-rust">filter: "warn,test_spiral=trace".to_string(),</code></pre>
510509
<p>now run</p>
511510
<pre><code> Running `target/debug/test_spiral`
@@ -528,12 +527,12 @@ <h3 id="module"><a class="header" href="#module">Module</a></h3>
528527
2024-10-19T22:24:06.016247Z TRACE test_spiral::spammy: i=8
529528
2024-10-19T22:24:06.016251Z TRACE test_spiral::spammy: i=9
530529
</code></pre>
531-
<p>In this case you can see the print_trash module ran before my setup code.
532-
also note that the crate module path was printed <code>test_spiral::spammy</code> this will soon be relevant</p>
530+
<p>In this case, you can see that the <code>print_trash</code> module ran before my setup code.
531+
Also note that the crate module path was printed <code>test_spiral::spammy</code>. This will soon be relevant</p>
533532
<h4 id="filter-out-by-module"><a class="header" href="#filter-out-by-module">Filter out by module</a></h4>
534-
<p>Clearly we have a problem with spammy, we could just delete the spammy logs like we would have to do with techniques in the previous chapter.
535-
However for the sake of the excercies lets pretend that we sometimes is useful</p>
536-
<p>Lets put in a log code so we cannot just change the applications logging levels</p>
533+
<p>Clearly we have a problem with spammy. We could just delete the spammy logs like we would have to do with techniques in the previous chapter.
534+
However, for the sake of the excercie, let's pretend that we sometimes is useful.</p>
535+
<p>Let's put in a log code so we cannot just change the application's logging levels</p>
537536
<pre><code class="language-rust">fn setup(
538537
mut commands: Commands,
539538
mut meshes: ResMut&lt;Assets&lt;Mesh&gt;&gt;,
@@ -555,9 +554,9 @@ <h4 id="filter-out-by-module"><a class="header" href="#filter-out-by-module">Fil
555554
2024-10-19T22:32:17.218967Z INFO test_spiral: Hello Log
556555
2024-10-19T22:32:17.218988Z DEBUG test_spiral: Don't hide me
557556
</code></pre>
558-
<p>If a log does not appear that I think should, I usually just put in at <code>error</code> and copy the path.</p>
557+
<p>If a log does not appear as I think it should, I usually just put it as an <code>error</code> and copy the path.</p>
559558
<p>We can now selectively hide messages when we need to! This exciting idea is what lead me to learning more about the tracing crate.</p>
560-
<p>But what about showing line numbers and extra details, this will be covered in the next chapter</p>
559+
<p>But what about showing line numbers and extra details? This will be covered in the next chapter.</p>
561560

562561
</main>
563562

0 commit comments

Comments
 (0)