Skip to content

Commit

Permalink
Deployed 51ffe3f to devel with MkDocs 1.2.4 and mike 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
skullydazed committed Feb 4, 2024
1 parent 0fdc29b commit 4075b30
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 8 deletions.
5 changes: 5 additions & 0 deletions devel/api_milc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,11 @@ <h4 id="initialize_logging">initialize_logging<a class="headerlink" href="#initi
<div class="highlight"><pre><span></span><code><span class="k">def</span> <span class="nf">initialize_logging</span><span class="p">(</span><span class="n">logger</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">logging</span><span class="o">.</span><span class="n">Logger</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="kc">None</span>
</code></pre></div>
<p>Prepare the defaults for the logging infrastructure.</p>
<p><a id="milc.MILC.initialize_arguments"></a></p>
<h4 id="initialize_arguments">initialize_arguments<a class="headerlink" href="#initialize_arguments" title="Permanent link">&para;</a></h4>
<div class="highlight"><pre><span></span><code><span class="k">def</span> <span class="nf">initialize_arguments</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kc">None</span>
</code></pre></div>
<p>Setup and add default arguments.</p>
<p><a id="milc.MILC.acquire_lock"></a></p>
<h4 id="acquire_lock">acquire_lock<a class="headerlink" href="#acquire_lock" title="Permanent link">&para;</a></h4>
<div class="highlight"><pre><span></span><code><span class="k">def</span> <span class="nf">acquire_lock</span><span class="p">(</span><span class="n">blocking</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span>
Expand Down
39 changes: 37 additions & 2 deletions devel/logging/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,13 @@
Controlling Log Output
</a>

</li>

<li class="md-nav__item">
<a href="#custom-loggers" class="md-nav__link">
Custom Loggers
</a>

</li>

</ul>
Expand Down Expand Up @@ -744,6 +751,13 @@
Controlling Log Output
</a>

</li>

<li class="md-nav__item">
<a href="#custom-loggers" class="md-nav__link">
Custom Loggers
</a>

</li>

</ul>
Expand All @@ -764,8 +778,6 @@



<h1>Logging</h1>

<p>MILC comes with a robust logging system based on python's <code>logging</code> module. All you have to worry about are log messages, let MILC worry about presenting those messages to the user in configurable ways.</p>
<h2 id="writing-log-entries">Writing Log Entries<a class="headerlink" href="#writing-log-entries" title="Permanent link">&para;</a></h2>
<p>A python <a href="https://docs.python.org/3/library/logging.html#logger-objects">Logger Object</a> is available as <code>cli.log</code>. You can use this to write messages at various log levels:</p>
Expand Down Expand Up @@ -813,6 +825,29 @@ <h2 id="controlling-log-output">Controlling Log Output<a class="headerlink" href
</ul>
</li>
</ul>
<h1 id="custom-loggers">Custom Loggers<a class="headerlink" href="#custom-loggers" title="Permanent link">&para;</a></h1>
<p>You may want to bypass MILC's logging and use your own logger instead. To do this use <code>cli.milc_options(logger=&lt;MyLogger&gt;)</code>. This should be done before you call <code>cli()</code> or do anything else.</p>
<p>Example:</p>
<div class="highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">logging</span>

<span class="kn">from</span> <span class="nn">milc</span> <span class="kn">import</span> <span class="n">cli</span>


<span class="nd">@cli</span><span class="o">.</span><span class="n">entrypoint</span><span class="p">(</span><span class="s1">&#39;Hello, World!&#39;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">hello</span><span class="p">(</span><span class="n">cli</span><span class="p">):</span>
<span class="n">cli</span><span class="o">.</span><span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;Hello, World!&#39;</span><span class="p">)</span>

<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">&#39;__main__&#39;</span><span class="p">:</span>
<span class="n">my_logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s1">&#39;my-program&#39;</span><span class="p">)</span>
<span class="c1"># Configure my_logger the way you want/need here</span>

<span class="n">cli</span><span class="o">.</span><span class="n">milc_options</span><span class="p">(</span><span class="n">logger</span><span class="o">=</span><span class="n">my_logger</span><span class="p">)</span>
<span class="n">cli</span><span class="p">()</span>
</code></pre></div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>You should only call <code>cli.milc_options()</code> one time during your program's execution.</p>
</div>


</article>
Expand Down
25 changes: 20 additions & 5 deletions devel/metadata/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,13 @@
Custom Loggers
</a>

</li>

<li class="md-nav__item">
<a href="#deprecated-set_metadata" class="md-nav__link">
Deprecated: set_metadata()
</a>

</li>

</ul>
Expand Down Expand Up @@ -722,6 +729,13 @@
Custom Loggers
</a>

</li>

<li class="md-nav__item">
<a href="#deprecated-set_metadata" class="md-nav__link">
Deprecated: set_metadata()
</a>

</li>

</ul>
Expand All @@ -743,12 +757,11 @@


<h1 id="milc-metadata">MILC Metadata<a class="headerlink" href="#milc-metadata" title="Permanent link">&para;</a></h1>
<p>In order to initialize some things, such as the configuration file location and the version number reported by <code>--version</code>, MILC needs to know some basic information before you import <code>cli</code>. If you need to set the program's name, author name, and/or version number do it like this:</p>
<div class="highlight"><pre><span></span><code><span class="kn">from</span> <span class="nn">milc</span> <span class="kn">import</span> <span class="n">set_metadata</span>

<span class="n">set_metadata</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;Florzelbop&#39;</span><span class="p">,</span> <span class="n">version</span><span class="o">=</span><span class="s1">&#39;1.0.0&#39;</span><span class="p">,</span> <span class="n">author</span><span class="o">=</span><span class="s1">&#39;Jane Doe&#39;</span><span class="p">)</span>
<p>In order to initialize some things, such as the configuration file location and the version number reported by <code>--version</code>, MILC needs to know some basic information before the entrypoint is called. You can use <code>cli.milc_options()</code> to set this information.</p>
<p>Example:</p>
<div class="highlight"><pre><span></span><code><span class="kn">from</span> <span class="nn">milc</span> <span class="kn">import</span> <span class="n">cli</span>

<span class="kn">from</span> <span class="nn">milc</span> <span class="kn">import</span> <span class="n">cli</span>
<span class="n">cli</span><span class="o">.</span><span class="n">milc_options</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;Florzelbop&#39;</span><span class="p">,</span> <span class="n">version</span><span class="o">=</span><span class="s1">&#39;1.0.0&#39;</span><span class="p">,</span> <span class="n">author</span><span class="o">=</span><span class="s1">&#39;Jane Doe&#39;</span><span class="p">)</span>
</code></pre></div>
<p>You should only do this once, and you should do it as early in your program's execution as possible.</p>
<div class="admonition danger">
Expand All @@ -765,6 +778,8 @@ <h2 id="custom-loggers">Custom Loggers<a class="headerlink" href="#custom-logger

<span class="kn">from</span> <span class="nn">milc</span> <span class="kn">import</span> <span class="n">cli</span>
</code></pre></div>
<h2 id="deprecated-set_metadata">Deprecated: set_metadata()<a class="headerlink" href="#deprecated-set_metadata" title="Permanent link">&para;</a></h2>
<p>Earlier versions of MILC used <code>milc.set_metadata</code> instead. This is still supported but will throw a Deprecation warning.</p>


</article>
Expand Down
2 changes: 1 addition & 1 deletion devel/search/search_index.json

Large diffs are not rendered by default.

Binary file modified devel/sitemap.xml.gz
Binary file not shown.
4 changes: 4 additions & 0 deletions devel/subcommand_config/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,10 @@ <h1 id="milc-config-subcommand">MILC config subcommand<a class="headerlink" href
<h1 id="introduction">Introduction<a class="headerlink" href="#introduction" title="Permanent link">&para;</a></h1>
<p>Configuration for MILC applications is a key/value system. Each key consists of a subcommand and an argument name separated by a period. This allows for a straightforward and direct translation between config keys and the arguments they set. You can provide your users with a subcommand for managing this configuration by importing the config subcommand:</p>
<p><code>import milc.subcommand.config</code></p>
<div class="admonition warn">
<p class="admonition-title">Warn</p>
<p>This must be imported after <code>cli.milc_options()</code> is used.</p>
</div>
<p>Read on to see how users can utilize this subcommand.</p>
<h2 id="simple-example">Simple Example<a class="headerlink" href="#simple-example" title="Permanent link">&para;</a></h2>
<p>As an example let's look at the command <code>my_cli foo --arg1 bar --arg2 bat</code>.</p>
Expand Down

0 comments on commit 4075b30

Please sign in to comment.