tag:blogger.com,1999:blog-78149291787598067502024-02-26T00:23:52.761-08:00Pantheios Tips 'n' TricksThe diary of the world's fastest, most flexible, and most robust C++ logging API library.Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.comBlogger34125tag:blogger.com,1999:blog-7814929178759806750.post-89716018042731627042020-06-13T16:39:00.000-07:002020-06-13T16:39:14.756-07:00Pantheios.Ruby Tutorial, part 2: First ProgramThis is the second part in a series of tutorial posts illustrating how to use <a href="http://github.com/synesissoftware/Pantheios.Ruby"><b>Pantheios.Ruby</b></a>. The first part is <a href="http://blog.pantheios.org/2020/06/pantheiosruby-tutorial-1-basic-script.html">here</a>.<br />
<h2>
<span style="font-size: large;">Project Setup</span></h2>
In this part we're going to do some basic project setup. Expert Rubyists may wish to skip to the next section.<br />
<br />
First step is to create a git project. Create a new directory and do a <b><a href="https://git-scm.com/">Git</a></b> init:<br />
<br />
<div>
<span style="font-family: "courier new" , "courier" , monospace;">$ git init</span><br />
<br /></div>
I'm going to use <b><a href="https://bundler.io/">Bundler</a></b>, so next do a <b>Bundle</b> init:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">$ bundle init</span><br />
<br />
I happen to know that we'll be using <b>recls.Ruby</b> as well as <a href="http://github.com/synesissoftware/Pantheios.Ruby"><b>Pantheios.Ruby</b></a>, so let's edit the generated bundle file to look something like the following:<br />
<br />
<div class="p1" style="color: #5620f4; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s2" style="background-color: white; font-variant-ligatures: no-common-ligatures;"><span style="color: #d17125;"> </span># frozen_string_literal: true</span></div>
<div class="p2" style="color: #d17125; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="background-color: white;"> </span></div>
<div class="p3" style="color: #ca3323; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="background-color: white;"><span class="s3" style="color: black; font-variant-ligatures: no-common-ligatures;"> source </span><span class="s4" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">"</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">https://rubygems.org</span><span class="s4" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">"</span></span></div>
<div class="p2" style="color: #d17125; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="background-color: white;"> </span></div>
<div class="p4" style="font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="background-color: white;"><span class="s2" style="font-variant-ligatures: no-common-ligatures;"> git_source(</span><span class="s5" style="color: #ca3323; font-variant-ligatures: no-common-ligatures;">:github</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">) {|</span><span class="s6" style="color: #38b9c7; font-variant-ligatures: no-common-ligatures;">repo_name</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">| </span><span class="s4" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">"</span><span class="s5" style="color: #ca3323; font-variant-ligatures: no-common-ligatures;">https://github.com/</span><span class="s4" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">#{</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">repo_name</span><span class="s4" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">}"</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;"> }</span></span></div>
<div class="p2" style="color: #d17125; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="background-color: white;"> </span></div>
<div class="p3" style="color: #ca3323; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="background-color: white;"><span style="color: #d17125;"> </span><span class="s3" style="color: black; font-variant-ligatures: no-common-ligatures;">gem </span><span class="s4" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">"</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">pantheios-ruby</span><span class="s4" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">"</span><span style="color: #d17125;"> </span></span></div>
<div class="p3" style="color: #ca3323; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="background-color: white;"><span style="color: #d17125;"> </span><span class="s3" style="color: black; font-variant-ligatures: no-common-ligatures;">gem </span><span class="s4" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">"</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">recls-ruby</span><span class="s4" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">"</span><span style="color: #d17125;"> </span></span></div>
<br />
Then just bundle it:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">$ bundle</span><br />
<br />
All being well, add <b>Gemfile</b> and the newly generated <b>Gemfile.lock</b> into git and commit.<br />
<h2>
<span style="font-size: large;">First Program</span></h2>
<div>
Ok, now on to the first program. First create the script <b>searcher.rb</b> and <span style="font-family: Courier New, Courier, monospace;">require</span> and <span style="font-family: Courier New, Courier, monospace;">include</span> both libraries, as follows:</div>
<div>
<br /></div>
<div>
<div class="p1" style="color: #db27da; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="background-color: white;"><span class="s1" style="color: #d17125; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>1 </span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">#! /usr/bin/env ruby</span></span></div>
<div class="p2" style="color: #d17125; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s2" style="background-color: white; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>2<span class="Apple-converted-space"> </span></span></div>
<div class="p3" style="color: #ca3323; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="background-color: white;"><span class="s1" style="color: #d17125; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>3 </span><span class="s3" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">require</span><span class="s4" style="color: black; font-variant-ligatures: no-common-ligatures;"> </span><span class="s3" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">"</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">pantheios</span><span class="s3" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">"</span></span></div>
<div class="p1" style="color: #db27da; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="background-color: white;"><span class="s1" style="color: #d17125; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>4 </span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">require</span><span class="s4" style="color: black; font-variant-ligatures: no-common-ligatures;"> </span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">"</span><span class="s5" style="color: #ca3323; font-variant-ligatures: no-common-ligatures;">recls</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">"</span></span></div>
<div class="p2" style="color: #d17125; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s2" style="background-color: white; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>5<span class="Apple-converted-space"> </span></span></div>
<div class="p4" style="color: #39c026; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="background-color: white;"><span class="s1" style="color: #d17125; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>6 </span><span class="s3" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">include</span><span class="s4" style="color: black; font-variant-ligatures: no-common-ligatures;"> ::</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">Pantheios</span></span></div>
<div class="p2" style="color: #d17125; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s2" style="background-color: white; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>7<span class="Apple-converted-space"> </span></span></div>
</div>
<div>
<br /></div>
<div>
Give it a run to verify <b><a href="https://bundler.io/">Bundler</a></b> did its job ok.</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">$ ruby searcher.rb</span><br />
<br /></div>
<div>
Go ahead and commit that, then we'll make it a little interesting by doing a search and logging some output.</div>
<div>
<br /></div>
<div>
<div class="p1" style="color: #db27da; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s1" style="color: #d17125; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>1 </span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">#! /usr/bin/env ruby</span></div>
<div class="p2" style="color: #d17125; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s2" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>2<span class="Apple-converted-space"> </span></span></div>
<div class="p3" style="color: #ca3323; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s1" style="color: #d17125; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>3 </span><span class="s3" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">require</span><span class="s4" style="color: black; font-variant-ligatures: no-common-ligatures;"> </span><span class="s3" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">"</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">pantheios</span><span class="s3" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">"</span></div>
<div class="p1" style="color: #db27da; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s1" style="color: #d17125; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>4 </span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">require</span><span class="s4" style="color: black; font-variant-ligatures: no-common-ligatures;"> </span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">"</span><span class="s5" style="color: #ca3323; font-variant-ligatures: no-common-ligatures;">recls</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">"</span></div>
<div class="p2" style="color: #d17125; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s2" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>5<span class="Apple-converted-space"> </span></span></div>
<div class="p4" style="color: #39c026; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s1" style="color: #d17125; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>6 </span><span class="s3" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">include</span><span class="s4" style="color: black; font-variant-ligatures: no-common-ligatures;"> ::</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">Pantheios</span></div>
<div class="p2" style="color: #d17125; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s2" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>7<span class="Apple-converted-space"> </span></span></div>
<div class="p5" style="font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s1" style="color: #d17125; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>8 </span><span class="s6" style="color: #39c026; font-variant-ligatures: no-common-ligatures;">Recls</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">.file_rsearch(</span><span class="s5" style="color: #ca3323; font-variant-ligatures: no-common-ligatures;">nil</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="s5" style="color: #ca3323; font-variant-ligatures: no-common-ligatures;">nil</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">).each </span><span class="s1" style="color: #d17125; font-variant-ligatures: no-common-ligatures;">do</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;"> |</span><span class="s7" style="color: #38b9c7; font-variant-ligatures: no-common-ligatures;">fe</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">|</span></div>
<div class="p2" style="color: #d17125; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s2" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>9<span class="Apple-converted-space"> </span></span></div>
<div class="p5" style="font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s1" style="color: #d17125; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>10 </span><span class="s2" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>log(</span><span class="s5" style="color: #ca3323; font-variant-ligatures: no-common-ligatures;">:informational</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">, </span><span class="s3" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">"</span><span class="s5" style="color: #ca3323; font-variant-ligatures: no-common-ligatures;">found '</span><span class="s3" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">#{</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">fe.search_relative_path</span><span class="s3" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">}</span><span class="s5" style="color: #ca3323; font-variant-ligatures: no-common-ligatures;">'</span><span class="s3" style="color: #db27da; font-variant-ligatures: no-common-ligatures;">"</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">)</span></div>
<div class="p2" style="color: #d17125; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s2" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>11 end</span><span class="s4" style="color: black; font-variant-ligatures: no-common-ligatures;"> </span></div>
<div class="p2" style="color: #d17125; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s2" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span>12 </span><span class="s4" style="color: black; font-variant-ligatures: no-common-ligatures;"> </span></div>
</div>
<div>
<br /></div>
<div>
This uses the <a href="https://www.rubydoc.info/gems/recls-ruby/2.11.0/Recls"><b><span style="font-family: Courier New, Courier, monospace;">Recls</span></b> module</a> function <span style="font-family: Courier New, Courier, monospace;"><a href="https://www.rubydoc.info/gems/recls-ruby/2.11.0/Recls#file_rsearch-class_method">file_rsearch()</a></span> to conduct a recursive search for files, returning an <span style="font-family: Courier New, Courier, monospace;"><a href="https://ruby-doc.org/core-2.7.1/Enumerable.html"><b>Enumerable</b></a></span> object on which we call each passing the block that uses <a href="http://github.com/synesissoftware/Pantheios.Ruby"><b>Pantheios.Ruby</b></a>'s <span style="font-family: Courier New, Courier, monospace;">log()</span> method to record each item found. On my machine it produces the following output</div>
<div>
<br /></div>
<div>
<div class="p1" style="font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s1" style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[searcher, 70123163703220, 2020-06-14 09:31:35.142106, Informational]: found 'searcher.rb'</span></span></div>
<div class="p1" style="font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s1" style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[searcher, 70123163703220, 2020-06-14 09:31:35.142559, Informational]: found 'Gemfile'</span></span></div>
<div class="p1" style="font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s1" style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[searcher, 70123163703220, 2020-06-14 09:31:35.143248, Informational]: found 'Gemfile.lock'</span></span></div>
</div>
<div>
<br /></div>
<div>
In the next instalment we'll examine the aspects of this program and its output and make some customisations to what gets logged and in what form.</div>
<div>
<br /></div>
<div>
<br /></div>
Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-9902954694082866332020-06-12T17:21:00.002-07:002020-06-13T17:34:25.111-07:00Pantheios.Ruby Tutorial, part 1: Basic ScriptSo, this'll be the first of a set of tutorials explaining how to use <a href="http://github.com/synesissoftware/Pantheios.Ruby">Pantheios.Ruby</a>.<br />
<br />
<h2>
Install and Verify</h2>
<br />
The first thing to do is install it, which is done as simply as:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">$ gem install pantheios-ruby</span><br />
<br />
(You may need/prefer to download the <a href="https://rubygems.org/gems/pantheios-ruby/">latest gem from <b>rubygems</b></a> and install from a local gem file. You may need the right privileges, so could require <span style="font-family: "courier new" , "courier" , monospace;">sudo</span>.)<br />
<br />
You can then verify the installation with the one-line:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">$ ruby -e 'require "pantheios" ; puts Pantheios::VERSION;'</span><br />
<br />
and should see output such as:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">0.22.0</span><br />
<h2>
Basic Script</h2>
Next, we'll create a minimally-featured script that does some logging. Using vim - I mean, what <i>else</i> is there?! - create a script <b>hello_pantheios.rb</b> with the following contents:<br />
<br />
<div class="p1" style="background-color: white; color: #d53bd3; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s1" style="color: #cd7923; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span></span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">#! /usr/bin/env ruby</span></div>
<div class="p2" style="background-color: white; color: #cd7923; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s2" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span></span></div>
<div class="p3" style="background-color: white; color: #c33720; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s1" style="color: #cd7923; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span></span><span class="s3" style="color: #d53bd3; font-variant-ligatures: no-common-ligatures;">require</span><span class="s4" style="color: black; font-variant-ligatures: no-common-ligatures;"> </span><span class="s3" style="color: #d53bd3; font-variant-ligatures: no-common-ligatures;">"</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">pantheios</span><span class="s3" style="color: #d53bd3; font-variant-ligatures: no-common-ligatures;">"</span></div>
<div class="p2" style="background-color: white; color: #cd7923; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s2" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span></span></div>
<div class="p4" style="background-color: white; color: #34bc26; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s1" style="color: #cd7923; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span></span><span class="s3" style="color: #d53bd3; font-variant-ligatures: no-common-ligatures;">include</span><span class="s4" style="color: black; font-variant-ligatures: no-common-ligatures;"> ::</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">Pantheios</span></div>
<div class="p2" style="background-color: white; color: #cd7923; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s2" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span></span></div>
<div class="p3" style="background-color: white; color: #c33720; font-family: Menlo; font-size: 11px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s1" style="color: #cd7923; font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space"> </span></span><span class="s4" style="color: black; font-variant-ligatures: no-common-ligatures;">log(</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">:notice</span><span class="s4" style="color: black; font-variant-ligatures: no-common-ligatures;">, </span><span class="s3" style="color: #d53bd3; font-variant-ligatures: no-common-ligatures;">"</span><span class="s2" style="font-variant-ligatures: no-common-ligatures;">Hello, World of Logs!</span><span class="s3" style="color: #d53bd3; font-variant-ligatures: no-common-ligatures;">"</span><span class="s4" style="color: black; font-variant-ligatures: no-common-ligatures;">)</span></div>
<br />
and then execute as follows:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">$ ruby hello_pantheios.rb</span><br />
<br />
you'll see output such as:<br />
<br />
<div class="p1" style="-webkit-text-stroke-color: rgb(0, 0, 0); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span class="s1" style="font-kerning: none;"><span style="font-family: "courier new" , "courier" , monospace;">[hello_pantheios, 70345600268220, 2020-06-13 10:09:21.867107, Notice]: Hello, World of Logs!</span></span></div>
<br />
<h2>
<span style="font-family: inherit;">Coming up:</span></h2>
In the next post we'll create a first version of a file-system search program with which we will illustrate a whole raft of <b>Pantheios.Ruby</b> features, including (but not limited to):<br />
<br />
<ul>
<li>using different severity levels and ascribing meaning to those levels;</li>
<li>filtering based on severity levels, including using front-ends to make decisions about which severity levels will be output;</li>
<li>choosing back-ends, i.e. where logged output goes, including:</li>
<ul>
<li>logging to the console;</li>
<li>logging to the console with severity level-related colours;</li>
<li>files;</li>
<li>syslog;</li>
<li>Ruby's standard logger;</li>
<li>log4r;</li>
<li>... and so on;</li>
</ul>
<li>naming threads;</li>
<li>customising the prefix - the bit above that contains "<span style="font-family: "courier new" , "courier" , monospace;"><span style="font-size: x-small;">[hello_pantheios, 70345600268220, 2020-06-13 10:09:21.867107, Notice]: </span></span>";</li>
<li>... and many more things I can't think of right now. That's why we're going to write an actually useful program to exercise it.</li>
</ul>
<div>
<br /></div>
<div>
<br /></div>
Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-26555794917412099842020-06-08T15:14:00.001-07:002020-06-08T15:14:41.866-07:00Pantheios : what's coming up in 2020?Well, folks, it's been a long while and not much activity on this blog. As you may've noticed, I've started blogging daily this last week, and aim to try and keep up at least a weekly update henceforth.<br />
<br />
Despite the lack of activity on the blog there's been a lot of work on various Pantheios projects. Here's a summary of what's been happening, and what's planned for the rest of 2020:<br />
<br />
<br />
<ul>
<li>The website will get a <i style="font-weight: bold;">long</i>-awaited update;</li>
<li>The <b>Pantheios main</b> (<b>C/C++</b>) project: </li>
<ul>
<li>will have fewer than ten more betas over the next couple of months;</li>
<li>the next beta off the rank will include:</li>
<ul>
<li>the <a href="http://blog.pantheios.org/2020/06/expanding-stock-severity-levels.html">expanded stock severity levels</a>;</li>
<li>an example of how to use the old severity levels;</li>
<li>examples of how to use custom severity levels;</li>
<li>will support VC++ up to 16.x (VS2019);</li>
<li>will support latest versions of GCC;</li>
<li>will have (auto-generated) solution and project files for all versions of VC++ from 10+ (VS2010+);</li>
<li>... and a bunch more stuff;</li>
</ul>
<li>will go into a final 1.0.1 release before the end of the year;</li>
<li>will use a different mechanism for linking to its dependency projects - TBD;</li>
<li>will get CMake builds this year;</li>
<li>will get installable packages early next year;</li>
</ul>
<li>The <b>Pantheios.Ruby</b> project:</li>
<ul>
<li>has been released, currently available via <a href="https://github.com/synesissoftware/Pantheios.Ruby"><b>GitHub</b></a> and as a <a href="https://rubygems.org/gems/pantheios-ruby/versions"><b>gem</b></a>;</li>
<li>will be documented soon;</li>
</ul>
<li>The <b>Pantheios.NET</b> project:</li>
<ul>
<li>has been updated just a couple of days ago with the new <a href="http://blog.pantheios.org/2020/06/expanding-stock-severity-levels.html">expanded stock severity levels</a>, available via <b><a href="https://www.nuget.org/packages/Pantheios.NET/">Nuget</a></b>;</li>
<li>will be getting its own website - pantheios.net - including tutorials and samples;</li>
<li>will be open-sourced before the end of the year - currently only available as Nuget packages.</li>
</ul>
<li>The <b>Pantheios.COM</b> project:</li>
<ul>
<li>will be getting a minor upgrade in order to account for the new <a href="http://blog.pantheios.org/2020/06/expanding-stock-severity-levels.html">expanded stock severity levels</a>;</li>
</ul>
</ul>
<div>
<br /></div>
<div>
Also possible are either/both of the nascent <b>Pantheios.Go</b> and/or <b>Pantheios.Python</b> project being released.</div>
Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-77577246022403992012020-06-08T13:30:00.000-07:002020-06-08T13:30:00.738-07:00Pantheios is a Diagnostic Logging *API* libraryJust a reminder to any old/new users of Pantheios: it is a <b>diagnostic logging <i>API</i> library</b>. The <i>API</i> bit is crucial. While each language implementation of Pantheios - C/C++, C#, Ruby, ... - does come with a bunch of stock "back-ends" that allow some fairly useful logging, it is a primary design parameter that it should be used as a superior API over existing sophisticated logging libraries.<br />
<br />
There'll be posts illustrating just how this is achieved for various languages over the coming weeks.Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-42766338568096547342020-06-07T11:30:00.000-07:002020-06-07T11:30:06.404-07:00Pantheios.NET / SynesisSoftware.Pantheios.NET.Extensions 0.12.1061 released<br />
<h2>
CHANGES:</h2>
<div>
<ul>
<li>added dynamic loading of components named in app.config from entry assembly directory</li>
<li>issues a contingent report when a thread fails with an uncaught exception</li>
<li>fixed defect in <b>SynesisSoftware.Pantheios.Scopes</b>' <span style="font-family: "courier new" , "courier" , monospace;">Pantheios.ApplicationLayer.Scopes.MethodTraceScope</span></li>
<li>added <b>Pantheios.Testing</b> library that provides the <span style="font-family: "courier new" , "courier" , monospace;">Pantheios.Testing.Services.RecordingService</span> service</li>
</ul>
</div>
<br />
<h2>
Releases on Nuget:</h2>
<ul>
<li><a href="https://www.nuget.org/packages/Pantheios.NET/0.12.1061">Pantheios.NET 0.12.1061</a></li>
<li><a href="https://www.nuget.org/packages/SynesisSoftware.Pantheios.NET.Extensions/0.12.1061">SynesisSoftware.Pantheios.NET.Extensions 0.12.1061</a></li>
</ul>
<div>
<br /></div>
Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-41597722626036230482020-06-06T20:35:00.001-07:002020-06-07T02:53:11.167-07:00Expanding the Stock Severity Levels<h2>
Original Severity Levels</h2>
The original <a href="https://github.com/synesissoftware/Pantheios"><b>Pantheios</b> C/C++ library</a> defined eight severity levels (and their integral values and string forms), as follows:<br />
<div>
<style type="text/css">
table {
border: 1;
}
th, td {
padding: 5px;
}
table.severities td.pan-td-right {
text-align: right;
}
</style>
<br />
<br />
<table border="1" class="severities" margin="">
<tbody>
<tr>
<th>Manifest constant</th>
<th>Integral value</th>
<th>String form<span style="font-weight: normal;"> (<span style="font-size: xx-small;"><sup>1</sup></span>)</span></th>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_EMERGENCY</span>
</td>
<td class="pan-td-right">0
</td>
<td>"Emergency"
</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_ALERT</span>
</td><td class="pan-td-right">1
</td>
<td>"Alert"
</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_CRITICAL</span>
</td><td class="pan-td-right">2
</td>
<td>"Critical"
</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_ERROR</span>
</td><td class="pan-td-right">3
</td>
<td>"Error"
</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_WARNING</span>
</td><td class="pan-td-right">4
</td>
<td>"Warning"
</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_NOTICE</span>
</td><td class="pan-td-right">5
</td>
<td>"Notice"
</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_INFORMATIONAL</span>
</td><td class="pan-td-right">6
</td>
<td>"Informational"
</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_DEBUG</span>
</td><td class="pan-td-right">7
</td>
<td>"Debug"
</td>
</tr>
</tbody></table>
</div>
<div>
<br />
<span style="font-size: x-small;">1. <span style="text-align: center;">as obtained by </span></span><span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small; text-align: center;">pantheios_getStockSeverityString()</span><br />
<br />
For anyone familiar with <b><a href="https://en.wikipedia.org/wiki/Syslog">Syslog</a></b>, these level names and values will be very familiar, as they exactly match:<br />
<br />
<div>
<br class="Apple-interchange-newline" />
<table border="1" class="severities"><tbody>
<tr><th>Manifest constant</th><th>Integral value</th></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">Emergency</span></td><td class="pan-td-right">0</td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">Alert</span></td><td class="pan-td-right">1</td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">Critical</span></td><td class="pan-td-right">2</td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">Error</span></td><td class="pan-td-right">3</td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">Warning</span></td><td class="pan-td-right">4</td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">Notice</span></td><td class="pan-td-right">5</td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">Informational</span> </td><td class="pan-td-right">6</td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">Debug</span></td><td class="pan-td-right">7</td></tr>
</tbody></table>
</div>
<div>
<br />
<h2>
Experiences and Evolution</h2>
However, over the decade and a half of use of Pantheios (and its other language bindings - .NET, Ruby, etc.) experience and further theoretical work has raised a number of issues, as discussed throughout the rest of this post.<br />
<br />
<h3>
"Error" -> "Failure"</h3>
<div>
As discussed in a <a href="https://accu.org/index.php/journals/1868">2013 instalment</a> of <b>Quality Matters</b> in ACCU's Overload, the term <i>error</i> is fraught with ambiguity: almost the whole industry uses the term incorrectly to mean a <i>failure</i> - "<i>throw an error</i>" - whereas an error is something that a human does in designing or building a system.</div>
<div>
<br /></div>
<div>
So, we've started to use the term <b>failure</b> instead. Newer Pantheios projects, such as <b><a href="http://github.com/synesissoftware/Pantheios.Ruby">Pantheios.Ruby</a></b>, already make use of this term, and the extant projects will evolve in that direction over the coming months.<br />
<br /></div>
<div>
<h3>
"Emergency" -> "Violation"</h3>
</div>
<div>
Just as the term <i>error</i> is ambiguous so is the term <i>bug</i>. The issues around both terms are dealt with more formally in <i>Contract Programming</i> / <i>Design by Contract</i>, which is beyond the scope of this post, but you can read up on it in Meyer's <i>Object-Oriented Software Construction</i> or Wilson's <i>Imperfect C++</i>.</div>
<div>
<br /></div>
<div>
<i>Contract Programming</i> makes a formal distinction between a failure of a system and a violation of a software contract. When a contract violation occurs the program has behaved in contradiction to its design so by definition it cannot "correct". The only sensible course of action in this case is to (attempt to) terminate the process, yielding control to the operating environment in the hope that the process <-> operating system abstraction can handle the situation.</-></div>
<div>
<br /></div>
<div>
Over the lifetime of Pantheios we have taken to using the <span style="font-family: "courier new" , "courier" , monospace;">Emergency</span> severity level <i>exclusively</i> for contract violations, and are starting to use the name <span style="font-family: "courier new" , "courier" , monospace;">Violation</span> instead. Again, newer projects already have this, and we're evolving others.</div>
<div>
<br /></div>
<div>
Later in this post we will discuss the meanings we ascribe to the severity levels.<br />
<br /></div>
<div>
<h3>
More debug levels</h3>
</div>
Extensive use in recent years of the Pantheios C/C++ library into sophisticated commercial C++ codebases with precise runtime controls over enabling/disabling severity levels has taught us that having a single debug level is insufficient. For example, when handling network traffic it is useful to be able to control the logging of the number of bytes received on a channel separate to the logging of all of those bytes.<br />
<br />
As such, we've tended to have a number of debugging levels: <span style="font-family: "courier new" , "courier" , monospace;">Debug0</span>, <span style="font-family: "courier new" , "courier" , monospace;">Debug1</span>, and so on, where each level involves deeper call levels and/or more extensive logged information. In the commercial projects we've provided <a href="http://blog.pantheios.org/2020/06/custom-severity-levels-with-pantheios.html">custom severities</a> with such additional levels, but plan to evolve the main Pantheios project along these lines soon.<br />
<br /></div>
<div>
<h3>
"Trace"</h3>
There is one (new) particular debugging level that stands out from the others: <span style="font-family: "courier new" , "courier" , monospace;">Trace</span>. This is useful for tracing function/method entry (including arguments received) and exit. Because tracing can lead to <i>heavy</i> amounts of logging, we have found it useful to give it a separate debugging level.<br />
<br />
Again, <a href="http://github.com/synesissoftware/Pantheios.Ruby" style="font-weight: bold;">Pantheios.Ruby</a> has this level already, and other projects will be getting it soon. The current tracing facilities provided by the <a href="https://github.com/synesissoftware/Pantheios"><b>Pantheios</b> C/C++ library</a> defined in <b><a href="https://github.com/synesissoftware/Pantheios/blob/master/include/pantheios/trace.h">pantheios/trace.h</a></b> will be adjusted to use the new severity level.<br />
<br />
<h3>
"Benchmark"</h3>
Finally, there is one (new) level that has emerged, for the exclusive purpose of benchmarking.<br />
<br />
<h2>
Pantheios.X 202x levels</h2>
Hence, what we might call the 202x levels for all Pantheios projects has emerged, as follows:<br />
<div>
<br class="Apple-interchange-newline" />
<table border="1" class="severities" margin=""><tbody>
<tr>
<th>Level name</th>
<th>String form</th>
<th>Former name</th>
<th>Integral value</th>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Violation</span></td>
<td>"Violation"</td>
<td><b><i>Emergency</i></b></td>
<td class="pan-td-right">1</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Alert</span></td>
<td>"Alert"</td>
<td><span style="color: #666666;">Alert</span></td>
<td class="pan-td-right">2</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Critical</span></td>
<td>"Critical"</td>
<td><span style="color: #666666;">Critical</span></td>
<td class="pan-td-right">3</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Failure</span></td>
<td>"Failure"</td>
<td><b><i>Error</i></b></td>
<td class="pan-td-right">4</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Warning</span></td>
<td>"Warning"</td>
<td><span style="color: #666666;">Warning</span></td>
<td class="pan-td-right">5</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Notice</span></td>
<td>"Notice"</td>
<td><span style="color: #666666;">Notice</span></td>
<td class="pan-td-right">6</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Informational</span></td>
<td>"Informational"</td>
<td><span style="color: #666666;">Informational</span></td>
<td class="pan-td-right">7</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Debug0</span></td>
<td>"Debug-0"</td>
<td><span style="color: #666666;">Debug</span></td>
<td class="pan-td-right">8</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Debug1</span></td>
<td>"Debug-1"</td>
<td>-</td>
<td class="pan-td-right">9</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Debug2</span></td>
<td>"Debug-2"</td>
<td>-</td>
<td class="pan-td-right">10</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Debug3</span></td>
<td>"Debug-3"</td>
<td>-</td>
<td class="pan-td-right">11</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Debug4</span></td>
<td>"Debug-4"</td>
<td>-</td>
<td class="pan-td-right">12</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Debug5</span></td>
<td>"Debug-5"</td>
<td>-</td>
<td class="pan-td-right">13</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Trace</span></td>
<td>"Trace"</td>
<td>-</td>
<td class="pan-td-right">14</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Benchmark</span></td>
<td>"Benchmark"</td>
<td>-</td>
<td class="pan-td-right">15</td>
</tr>
</tbody>
</table>
<br />
<div>
<br />
These levels already exist within <a href="http://github.com/synesissoftware/Pantheios.Ruby" style="font-weight: bold;">Pantheios.Ruby</a> and will be included in the next version of the <a href="https://github.com/synesissoftware/Pantheios"><b>Pantheios</b> C/C++ library</a> (albeit with a compile-time option to use the prior levels) and in the next release of <a href="https://www.nuget.org/packages/Pantheios.NET">Pantheios.NET</a>. (Each of these is likely to be within a month or two of this post.)<br />
<br /></div>
<h3>
Value changes</h3>
<div>
As well as the addition of new levels, and the renaming of two extant levels, you may also note that the values of the levels corresponding to the original eight have changed. Specifically, they are no longer 0-based, but are now 1-based. The reasons for this are:<br />
<br />
<ul>
<li>to help catch programming errors in some languages where a default-initialised level variable/parameter would be interpreted as Violation(/Emergency); and</li>
<li>to allow sophisticated front-ends to have an "all levels" value to facilitate group control. (We'll discuss this more fully in a future post.)</li>
</ul>
<div>
Note that all levels still fall within 4-bits, so the extended severity level information mechanism is still supported by the the <a href="https://github.com/synesissoftware/Pantheios"><b>Pantheios</b> C/C++ library</a>. (See <a href="http://blog.pantheios.org/2009/05/use-of-extended-severity-information.html">this post</a> about extended severity information. Also, the next release will include C and C++ examples of how to use extended severity information.)<br />
<br /></div>
</div>
<h3>
Ascribing meaning to levels</h3>
<div>
A <a href="http://blog.pantheios.org/2010/10/choosing-severity-levels.html">previous post on this blog</a> discusses the meanings we tend to ascribe to the 8 Syslog-derived levels. Naturally, if we're expanding the stock levels we need to take care to update this picture. In summary, we can say that we interpret them as follows, and offer it as a guide to you:<br />
<br />
<br /></div>
<table border="1" class="severities" margin="">
<tbody>
<tr>
<th>Level</th>
<th>Meaning</th>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Violation</span></td>
<td>Used exclusively in the attempt to record a contract violation</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Alert</span></td>
<td>Used to report a practically-unrecoverable runtime condition, i.e. one that will require imminent process termination but is not a fault</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Critical</span></td>
<td>Serious failure to achieve normative behaviour</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Error</span></td>
<td>Failure to achieve normative behaviour</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Warning</span></td>
<td>Warning condition</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Notice</span></td>
<td>Information to be logged in normal operation, meaning when there has been no need to increase the logging information above a normal condition</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Informational</span></td>
<td>Logging information that is useful when actively monitoring the health of a system, but that is not necessarily displayed as part of "normal" operation </td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Debug-0</span></td>
<td>Highest conceptual level and/or most terse form of debugging logging</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Debug-1</span></td>
<td>Next lower conceptual level and more verbose than <span style="font-family: "courier new" , "courier" , monospace;">Debug-0</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Debug-2</span></td>
<td>Next lower conceptual level and more verbose than <span style="font-family: "courier new" , "courier" , monospace;">Debug-1</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Debug-3</span></td>
<td>Next lower conceptual level and more verbose than <span style="font-family: "courier new" , "courier" , monospace;">Debug-2</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Debug-4</span></td>
<td>Next lower conceptual level and more verbose than <span style="font-family: "courier new" , "courier" , monospace;">Debug-3</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Debug-5</span></td>
<td>Lowest conceptual level and most verbose form of debugging logging</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Trace</span></td>
<td>Used exclusively to record function/method entry/exit (along with, optionally, function arguments)</td>
</tr>
<tr>
<td><span style="font-family: "courier new" , "courier" , monospace;">Benchmark</span></td>
<td>Used exclusively to emit terse statements - usually only a literal string, to cause least impact to system performance - for the express purpose of tracking system performance</td>
</tr>
</tbody></table>
</div>
</div>
</div>
Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-76507562568401077082020-06-05T20:56:00.004-07:002020-06-07T02:52:27.759-07:00Custom Severity Levels with Pantheios C/C++ projectBeen a bit of demand for this one, so here we go, <i>in as few words as possible</i>.<br />
<br />
<h3>
Stock Severity Levels</h3>
Out of the box, up to the present version (<a href="https://github.com/synesissoftware/Pantheios/releases">1.0.1 beta 218</a>) the <a href="https://github.com/synesissoftware/pantheios"><b>Pantheios</b> C/C++ library</a> comes with eight stock severity levels, as follows:<br />
<br />
<div>
<br />
<table border="1" class="severities" margin=""><tbody>
<tr><th>Manifest constant</th><th>Integral value</th><th>String form<span style="font-weight: normal;"> (<span style="font-size: xx-small;"><sup>1</sup></span>)</span></th></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_EMERGENCY</span></td><td class="pan-td-right">0</td><td>"Emergency"</td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_ALERT</span></td><td class="pan-td-right">1</td><td>"Alert"</td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_CRITICAL</span></td><td class="pan-td-right">2</td><td>"Critical"</td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_ERROR</span></td><td class="pan-td-right">3</td><td>"Error"</td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_WARNING</span></td><td class="pan-td-right">4</td><td>"Warning"</td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_NOTICE</span></td><td class="pan-td-right">5</td><td>"Notice"</td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_INFORMATIONAL</span> </td><td class="pan-td-right">6</td><td>"Informational" </td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_DEBUG</span></td><td class="pan-td-right">7</td><td>"Debug"</td></tr>
</tbody></table>
</div>
<div>
<br />
<span style="font-size: x-small;">1. <span style="text-align: center;">as obtained by </span></span><span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small; text-align: center;">pantheios_getStockSeverityString()</span><br />
<br />
These are defined in the file <b><a href="https://github.com/synesissoftware/Pantheios/blob/master/include/pantheios/pantheios.h">pantheios/pantheios.h</a></b> and are available for both C and C++ compilation units. Additionally, for C++ compilation units the following pseudo-constants are available:<br />
<br />
<div>
<br />
<table border="1" class="severities" margin=""><tbody>
<tr><th>C++ pseudo-constant (<span style="font-size: xx-small; font-weight: 400;"><sup>2</sup></span><span style="font-weight: 400;">)</span></th><th>Integral Value</th><th>Corresponding constant</th></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">pantheios::emergency</span></td><td class="pan-td-right">0</td><td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_EMERGENCY</span></td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">pantheios::alert</span></td><td class="pan-td-right">1</td><td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_ALERT</span></td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">pantheios::critical</span></td><td class="pan-td-right">2</td><td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_CRITICAL</span></td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">pantheios::error</span></td><td class="pan-td-right">3</td><td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_ERROR</span></td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">pantheios::warning</span></td><td class="pan-td-right">4</td><td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_WARNING</span></td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">pantheios::notice</span></td><td class="pan-td-right">5</td><td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_NOTICE</span></td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">pantheios::informational</span> </td><td class="pan-td-right">6</td><td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_INFORMATIONAL</span></td></tr>
<tr><td><span style="font-family: "courier new" , "courier" , monospace;">pantheios::debug</span></td><td class="pan-td-right">7</td><td><span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_SEV_DEBUG</span></td></tr>
</tbody></table>
</div>
<div>
<br />
<span style="font-size: x-small;">2. <span style="text-align: center;">these are defined </span></span><br />
<br />
These C++-only pseudo-constants also facilitate easily the use of extended severity information, but that's <a href="http:/#TBC">a topic for another time</a>.<br />
<br />
The string forms' C-style strings and string lengths are obtained, respectively, via the <span style="font-family: "courier new" , "courier" , monospace;">pantheios_getStockSeverityString()</span> and <span style="font-family: "courier new" , "courier" , monospace;">pantheios_getStockSeverityStringLength()</span> API functions.<br />
<br />
<h3>
Custom Severity Levels</h3>
If you want to use a different set of severities, then you must do the following:<br />
<ol>
<li><span style="font-family: "courier new" , "courier" , monospace;">#define</span> the preprocessor symbol <span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_NO_STOCK_LEVELS</span>;</li>
<li>link to a back-end of your own that understands your custom severity levels.</li>
</ol>
<div>
<br /></div>
<div>
Here's a C-program illustrating how to do this (with as much detail as possible elided for brevity):</div>
</div>
<br />
<table border="1" class="severities" margin=""><tbody>
<tr><td><span style="font-size: x-small;"><br /></span>
<br />
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="s1" style="color: #0433ff;">#define</span> PANTHEIOS_NO_STOCK_LEVELS </span><span style="color: #008f00; font-size: x-small;">/* suppress stock severity levels </span><span style="color: #008f00; font-size: x-small;">*/</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p3" style="color: #b4261a; font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="s1" style="color: #0433ff;">#include</span> <span class="s3" style="color: #b4261a;">⟨pantheios/pantheios.h⟩</span></span><span style="font-size: x-small;"></span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p4" style="color: #008f00; font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">/* some log4j-like levels </span><span style="font-size: x-small;">*/</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="s1" style="color: #0433ff;">enum</span> CustomSeverityLevel_t</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">{</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>CSL_Fatal = 0,</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>CSL_Error = 3,</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>CSL_Warn<span class="Apple-converted-space"> </span>= 4,</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>CSL_Info<span class="Apple-converted-space"> </span>= 6,</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>CSL_Debug = 7,</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">};</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p4" style="color: #008f00; font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">/* the application</span><span class="Apple-converted-space" style="font-size: x-small;"> </span><span style="font-size: x-small;">*/</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="s1" style="color: #0433ff;">int</span> main()</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">{</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">int</span> retCode = EXIT_SUCCESS;</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">int</span> res;</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>res = pantheios_init();</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">if</span>(0 != res)</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>{</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>fprintf(stderr, <span class="s3" style="color: #b4261a;">"Failed to initialise the Pantheios libraries: %s\n"</span>, pantheios_getInitCodeString(res));</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>retCode = EXIT_FAILURE;</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>}</span></div>
<div class="p5" style="color: #0433ff; font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="s2" style="color: black;"> </span>else</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>{</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>pantheios_logputs(CSL_Info, PANTHEIOS_LITERAL_STRING(<span class="s3" style="color: #b4261a;">"pantheios_logputs() can output a single C-style string"</span>));</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p4" style="color: #008f00; font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="s2" style="color: black;"><span class="Apple-converted-space"> </span></span>. . . //rest of program logic, including more pantheios_logputs() / pantheios_logprintf() statements</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>pantheios_uninit();</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>}</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">return</span> retCode;</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">}</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p4" style="color: #008f00; font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">/* the custom back-end </span><span style="font-size: x-small;">*/</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p3" style="color: #b4261a; font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="s1" style="color: #0433ff;">#include</span> <span class="s3" style="color: #b4261a;">⟨pantheios/backend.h⟩</span></span><span style="font-size: x-small;"></span></div>
<div class="p3" style="color: #b4261a; font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="s1" style="color: #0433ff;">#include</span> <span class="s3" style="color: #b4261a;">⟨pantheios/init_codes.h⟩</span></span><span style="font-size: x-small;"></span></div>
<div class="p3" style="color: #b4261a; font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="s1" style="color: #0433ff;">#include</span> <span class="s3" style="color: #b4261a;">⟨pantheios/strdup.h⟩</span></span><span style="font-size: x-small;"></span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">PANTHEIOS_CALL(<span class="s1" style="color: #0433ff;">int</span>) pantheios_be_init(</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>PAN_CHAR_T <span class="s1" style="color: #0433ff;">const</span>* processIdentity</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">, <span class="s1" style="color: #0433ff;">void</span>* <span class="Apple-converted-space"> </span>reserved</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">, <span class="s1" style="color: #0433ff;">void</span>**<span class="Apple-converted-space"> </span>ptoken</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">)</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">{</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>((<span class="s1" style="color: #0433ff;">void</span>)reserved);</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>*ptoken = pantheios_util_strdup_nothrow(processIdentity);</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">return</span> (NULL == *ptoken) ? PANTHEIOS_INIT_RC_OUT_OF_MEMORY : PANTHEIOS_INIT_RC_SUCCESS;</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">}</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">PANTHEIOS_CALL(<span class="s1" style="color: #0433ff;">void</span>) pantheios_be_uninit(<span class="s1" style="color: #0433ff;">void</span> *token)</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">{</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>pantheios_util_strfree((PAN_CHAR_T*)(token));</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">}</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">PANTHEIOS_CALL(<span class="s1" style="color: #0433ff;">int</span>) pantheios_be_logEntry( <span class="Apple-converted-space"> </span></span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">void</span>* <span class="Apple-converted-space"> </span>feToken</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">, <span class="s1" style="color: #0433ff;">void</span>* <span class="Apple-converted-space"> </span>beToken</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">, <span class="s1" style="color: #0433ff;">int</span> <span class="Apple-converted-space"> </span>severity</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">, PAN_CHAR_T <span class="s1" style="color: #0433ff;">const</span>* entry</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">, size_t<span class="Apple-converted-space"> </span>cchEntry</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">)</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">{</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>PAN_CHAR_T <span class="s1" style="color: #0433ff;">const</span>* sevString;</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>PAN_CHAR_T <span class="s1" style="color: #0433ff;">const</span>* processId = (PAN_CHAR_T <span class="s1" style="color: #0433ff;">const</span>*)(beToken);</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>((<span class="s1" style="color: #0433ff;">void</span>)feToken);</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">switch</span> (severity)</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>{</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">case</span> CSL_Fatal:</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"> sevString = PANTHEIOS_LITERAL_STRING(<span class="s3" style="color: #b4261a;">"Fatal"</span>);</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">break</span>;</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">case</span> CSL_Error:</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"> sevString = PANTHEIOS_LITERAL_STRING(<span class="s3" style="color: #b4261a;">"Error"</span>);</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">break</span>;</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">case</span> CSL_Warn:</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>sevString = PANTHEIOS_LITERAL_STRING(<span class="s3" style="color: #b4261a;">"Warn"</span>);</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">break</span>;</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">case</span> CSL_Info:</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>sevString = PANTHEIOS_LITERAL_STRING(<span class="s3" style="color: #b4261a;">"Info"</span>);</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">break</span>;</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">case</span> CSL_Debug:</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"> sevString = PANTHEIOS_LITERAL_STRING(<span class="s3" style="color: #b4261a;">"Debug"</span>);</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">break</span>;</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">default</span>:</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>sevString = PANTHEIOS_LITERAL_STRING(<span class="s3" style="color: #b4261a;">"<unknown severity="">"</unknown></span>);</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="s1" style="color: #0433ff;"> break</span>;</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>}</span></div>
<div class="p1" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<span style="font-size: x-small;"><br /></span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="s1" style="color: #0433ff;">#ifdef</span> PANTHEIOS_USE_WIDE_STRINGS</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">return</span> fwprintf(</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>stderr</span></div>
<div class="p3" style="color: #b4261a; font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="s2" style="color: black;"><span class="Apple-converted-space"> </span>, L</span>"[%s; %s]: %.*s\n"</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>, processId</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>, sevString</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>, (<span class="s1" style="color: #0433ff;">int</span>)cchEntry, entry</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>);</span></div>
<div class="p4" style="color: #008f00; font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="s1" style="color: #0433ff;">#else</span><span class="s2" style="color: black;"> </span>/* ? PANTHEIOS_USE_WIDE_STRINGS */</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span><span class="s1" style="color: #0433ff;">return</span> fprintf(</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>stderr</span></div>
<div class="p3" style="color: #b4261a; font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="s2" style="color: black;"><span class="Apple-converted-space"> </span>, </span>"[%s; %s]: %.*s\n"</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>, processId</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>, sevString</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>, (<span class="s1" style="color: #0433ff;">int</span>)cchEntry, entry</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="Apple-converted-space"> </span>);</span></div>
<div class="p4" style="color: #008f00; font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;"><span class="s1" style="color: #0433ff;">#endif</span><span class="s2" style="color: black;"> </span>/* PANTHEIOS_USE_WIDE_STRINGS */</span></div>
<div class="p2" style="font-family: Consolas; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;">
<span style="font-size: x-small;">}</span></div>
<div class="p1" style="font-family: Consolas; font-size: 8px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; min-height: 9px;">
<br /></div>
</td></tr>
</tbody></table>
<div>
</div>
</div>
Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-61128329223647677832019-02-05T14:08:00.000-08:002019-02-05T14:08:56.803-08:00Coming in 2019: Pantheios 1 (non-beta); Pantheios 2Ok, so it's been a heck of a long while since <b>Pantheios</b>' first beta was released. The <a href="https://github.com/synesissoftware/Pantheios/releases/tag/1.0.1-beta218">last released beta was 219</a> (!), on 28th January 2017. There's been a fair amount of useful work on the library since then, but not released.<br />
<br />
(As has been obvious since the outset of its release into the world, having the first version number as 1.0.1 and then just bumping the beta was crazy optimistic, and in practice just crazy. This very aspect has hindered speed of progress, as it's worked against the principle of <i><a href="https://en.wikipedia.org/wiki/Release_early,_release_often">release early, release often</a></i>.)<br />
<br />
There's also been a lot of change in "<i>the ideal conception of Pantheios in C/C++</i>" in this time. There are no massive changes, but there are some important differences that will require a bump in major number, which will be outlined in posts in the near future.<br />
<br />
Both of the above (as yet unreleased) works have arisen due to use and commercial customisations I've been doing for a client, in which <b>Pantheios</b> has seen tremendous use in exacting circumstances. (I say this to reassure that the project is <i>not</i> dead, not even resting, stunned, or pining for the fjords. It is alive, and it will be sprouting wings again into the world this year.)<br />
<br />
So, without much further ado, the coming changes of the Pantheios project are:<br />
<ul>
<li>The existing Pantheios project (1.0.1-bXXX) will be mothballed;</li>
<li>The current state of Pantheios will be effectively rendered in another project, <b>Pantheios1</b>;</li>
<li>The new, improved version will be rendered in another project, <b>Pantheios2</b>, sometime before the middle of the year. Subsequent posts will explain the new/changed features.</li>
</ul>
<br />
<br />Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-32603515054696862542015-09-27T16:14:00.001-07:002015-09-27T16:18:33.796-07:00Use of the showPlus format flag<a href="https://sourceforge.net/projects/pantheios/files/Pantheios%20%28C%20and%20Cxx%29/1.0.1%20%28beta%20215%29/"><b>Pantheios</b> 1.0.1 beta 215</a> introduces the <span style="font-family: Courier New, Courier, monospace;"><a href="https://github.com/synesissoftware/Pantheios/blob/master/include/pantheios/inserters/fmt.hpp">showPlus</a></span> format flag, which causes leading pluses to be applied to integers (just as leading minuses will appear for negative numbers).<br />
<br />
It is used as follows:<br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">#include <pantheios/pan.hpp></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">#include <pantheios/inserters/i.hpp></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">int main()</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">{</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("log -10:");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("without showPlus: '", pan::i(-10), "'");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("with showPlus: '", pan::i(-10, 0, <b>pan::fmt::showPlus</b>), "'");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("----------\n");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("log +10:");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("without showPlus: '", pan::i(+10), "'");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("with showPlus: '", pan::i(+10, 0, <b>pan::fmt::showPlus</b>), "'");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("----------\n");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("log -10 into 10-width:");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("without showPlus: '", pan::i(-10, 10, 0), "'");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("with showPlus: '", pan::i(-10, 10, <b>pan::fmt::showPlus</b>), "'");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("----------\n");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("log +10 into 10-width:");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("without showPlus: '", pan::i(+10, 10, 0), "'");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("with showPlus: '", pan::i(+10, 10, <b>pan::fmt::showPlus</b>), "'");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("----------\n");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("log -10 into 10-width left-justified:");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("without showPlus: '", pan::i(-10, -10, 0), "'");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("with showPlus: '", pan::i(-10, -10, <b>pan::fmt::showPlus</b>), "'");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("----------\n");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("log +10 into 10-width left-justified:");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("without showPlus: '", pan::i(+10, -10, 0), "'");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("with showPlus: '", pan::i(+10, -10, <b>pan::fmt::showPlus</b>), "'");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pan::log_INFORMATIONAL("----------\n");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> return 0;</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">}</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">PANTHEIOS_EXTERN_C PAN_CHAR_T const PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.scratch.showPlus.integer");</span><br />
<br />
which gives the output:<br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: log -10:</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: without showPlus: '-10'</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: with showPlus: '-10'</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: ----------</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: log +10:</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: without showPlus: '10'</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: with showPlus: '+10'</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: ----------</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: log -10 into 10-width:</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: without showPlus: ' -10'</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: with showPlus: ' -10'</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: ----------</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: log +10 into 10-width:</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: without showPlus: ' 10'</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: with showPlus: ' +10'</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: ----------</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: log -10 into 10-width left-justified:</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: without showPlus: '-10 '</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: with showPlus: '-10 '</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: ----------</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: log +10 into 10-width left-justified:</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: without showPlus: '10 '</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: with showPlus: '+10 '</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">[test.scratch.showPlus.integer...]: ----------</span><br />
<br />
<br />Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com2tag:blogger.com,1999:blog-7814929178759806750.post-79739562968193062672015-09-27T01:43:00.000-07:002019-10-17T21:39:36.903-07:00GitHub access<span style="font-family: "arial" , "helvetica" , sans-serif;">Pantheios GitHub access now at:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<ul>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://github.com/synesissoftware/Pantheios"><b>Pantheios</b></a> - main C/C++ library;</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://github.com/synesissoftware/Pantheios.Extras.DiagUtil"><b>Pantheios.Extras.DiagUtil</b></a> - <span style="font-size: 16px; line-height: 25px;">a suite of functions that aid diagnostics;</span></span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://github.com/synesissoftware/Pantheios.Extras.Main"><b>Pantheios.Extras.Main</b></a> - <span style="font-size: 16px; line-height: 25px;">which provides a suite of functions that simplify the implementation of </span><code style="border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; font-size: 14px; margin: 0px; padding: 0.2em 0px;">main()</code><span style="font-size: 16px; line-height: 25px;">; and</span></span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://github.com/synesissoftware/Pantheios.Extras.xHelpers"><b>Pantheios.Extras.xHelpers</b></a> - <span style="font-size: 16px; line-height: 25px;">a suite of free-function templates that simplify the implementation of non-throwing APIs</span>.</span></li>
</ul>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br />
Fork away!</span>Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-42671641433497413902015-09-27T01:24:00.000-07:002015-09-27T01:48:28.313-07:00Pantheios 1.0.1 beta 215 released<div style="font-size: 12px; margin-bottom: 5px; margin-top: 5px;">
<span style="font-family: Arial, Helvetica, sans-serif;">Pantheios is an open source C/C++ Logging API library, offering an optimal </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">combination of 100% type-safety, efficiency, genericity and extensibility. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">It is simple to use and extend, highly-portable (platform and </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">compiler-independent) and, best of all, it upholds the C tradition of you </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">only pay for what you use.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Pantheios supports logging of message statements of arbitrary complexity, </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">consisting of heterogeneous types.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Pantheios supports filtering of log messages based on severity level </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">including (but not limited to) the eight levels defined by the SysLog </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">protocol.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Pantheios supports back-end output, individually and in combination, to </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">stderr/stdout, SysLog (including a custom implementation of the SysLog </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">protocol for Windows), Windows debugger, Windows event log, COM Error </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Object, Speech, or any custom back-end extension you care to write. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Importantly, Pantheios is readily extended to use the existing transport </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">mechanisms of feature-rich logging libraries such as ACE, log4cpp, </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">log4cplus, log4cxx.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Pantheios does not contain any compiler-specific or platform-specific </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">constructs. It supports UNIX (including Linux and Mac OS-X), and Windows, </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">and should work with any operating system. It is known to be compatible with </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Borland (5.6+), Clang, Comeau (4.3.3+), Digital Mars (8.45+), GCC (3.4+), Intel </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">(7+), Metrowerks (8+), Microsoft Visual C++ (6.0+), and should work with any </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">reasonably modern C++ compiler.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Pantheios is completely free and includes source released under a BSD-style </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">license. Commercial servics, including bespoke customisations, are available </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">from Synesis Software Pty Ltd; <a href="http://synesis.com.au/contact.html"><span style="color: #0433ff;">http://synesis.com.au/contact.html</span></a></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Pantheios Training is provided by Synesis Software Pty Ltd; details at </span><br />
<a href="http://synesis.com.au/training.html"><span style="color: #0433ff; font-family: Arial, Helvetica, sans-serif;">http://synesis.com.au/training.html</span></a><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Release 1.0.1 beta 215 incorporates:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">* added interval inserter</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">* added stream_character inserter</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">* Clang-compatibility</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">* VC++ 11-compatibility</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">* VC++ 12-compatibility</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">* VC++ 14-compatibility</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">* showPlus format flag support in pantheios::integer (pan::i)</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">* makefiles customisable to specify non-bundled locations of b64, shwild, </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">xContract, xCover, and xTests libraries (useful to getting head from GitHub)</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">* NOTE: Now requires STLSoft 1.9.121</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Download from: </span><br />
<a href="https://sourceforge.net/projects/pantheios/files/Pantheios%20%28C%20and%20Cxx%29/"><span style="color: #0433ff; font-family: Arial, Helvetica, sans-serif;">https://sourceforge.net/projects/pantheios/files/Pantheios%20%28C%20and%20Cxx%29/</span></a><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Discuss at: <a href="https://sourceforge.net/projects/pantheios/forums/forum/475313"><span style="color: #0433ff;">https://sourceforge.net/projects/pantheios/forums/forum/475313</span></a></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Pantheios website: <a href="http://pantheios.org/"><span style="color: #0433ff;">http://pantheios.org/</span></a></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Note: this release of Pantheios requires STLSoft 1.9.121, or later; download </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">from <a href="http://stlsoft.org/"><span style="color: #0433ff;">http://stlsoft.org/</span></a> </span><br />
<div style="font-family: 'Times New Roman';">
<br /></div>
</div>
Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-44833795411481739232012-05-21T03:34:00.001-07:002012-05-21T03:34:48.231-07:00Extended Radio Silence - ending in Q3 2012To anyone who's still following any of my public works - FastFormat,
Pantheios, STLSoft, Breaking Up The Monolith, Quality Matters, VOLE,
etc. - and wondering whether these activities are permanently moribund, I
want to let you know that I'll soon be free of a very intense and
overwhelmingly consuming commercial engagement over the last 2.5 years,
and the second half of this year should see much activity in
open-source, commercial, and writing activities.<br />
<br />
Cheers<br />
<br />
MattMatt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com3tag:blogger.com,1999:blog-7814929178759806750.post-31357537708340436112011-01-10T01:46:00.000-08:002011-01-10T01:47:54.644-08:00Pantheios 1.0.1 beta 210 released: closing a vulnerability to badly written third-party librariesThe latest release of <a href="http://www.pantheios.org/"><b>Pantheios</b></a> - <a href="http://sourceforge.net/news/?group_id=141831&id=296069">version 1.0.1 beta 210</a> - closes a vulnerability to implicit conversion of instances of fundamental types in the presence of badly-written third-party C++ libraries.<br />
<br />
For reasons of <a href="http://quality-matters-to.us/definitions.html#robustness">robustness</a>, Pantheios log statements do not accept instances of fundamental types - integers, floating-points, <span style="font-family: "Courier New",Courier,monospace;">bool</span>, <span style="font-family: "Courier New",Courier,monospace;">char</span>, and so on. Instead, users are advised to select from the set of <a href="http://www.pantheios.org/doc/html/group__group____application__layer__interface____inserters.html">stock inserter classes and functions</a> provided with the library, or to define their own.<br />
<br />
Consequently, and <i>by design</i>, statements such as the following will result in compilation errors:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;"> #include <pantheios/pantheios.hpp><br />
<br />
pantheios::log_NOTICE("int: ", 10);<br />
<br />
pantheios::log_INFORMATIONAL("float: ", 1.23);<br />
<br />
pantheios::log_INFORMATIONAL("bool: ", true);<br />
</div><br />
Instead, inserters should be used:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;"> #include <pantheios/pantheios.hpp><br />
#include <pantheios/inserters/integer.hpp><br />
#include <pantheios/inserters/real.hpp><br />
#include <pantheios/inserters/boolean.hpp><br />
</div><br />
<div style="font-family: "Courier New",Courier,monospace;"> pantheios::log_NOTICE("int: ", <b>pantheios::integer</b>(10));<br />
<br />
pantheios::log_INFORMATIONAL("float: ", <b>pantheios::real</b>(1.23));<br />
<br />
pantheios::log_INFORMATIONAL("bool: ", <b>pantheios::boolean</b>(true));</div><br />
This can be expressed more succinctly by using namespace and inserter aliases:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;"> #include <pantheios/pan.hpp><br />
#include <pantheios/inserters/i.hpp><br />
#include <pantheios/inserters/real.hpp><br />
#include <pantheios/inserters/b.hpp><br />
</div><br />
<div style="font-family: "Courier New",Courier,monospace;"> pan::log_NOTICE("int: ", <b>pan::i</b>(10));<br />
<br />
pan::log_INFORMATIONAL("float: ", <b>pan::real</b>(1.23));<br />
<br />
pan::log_INFORMATIONAL("bool: ", <b>pan::b</b>(true));<br />
</div><br />
<div style="font-family: inherit;">Unfortunately, in the presence of <a href="http://en.wikipedia.org/wiki/Active_Template_Library"><b>ATL</b></a> or <a href="http://en.wikipedia.org/wiki/Microsoft_Foundation_Classes"><b>MFC</b></a> - or any other library that has conversion constructors and for which <i>string access shims</i> are defined - the former statements will compile and execute, but will not produce the expected output. Consider the following code:<br />
</div><div style="font-family: inherit;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">#include <afx.h><br />
#include <pantheios/pan.hpp><br />
<br />
pan::log_NOTICE("int: ", 10);<br />
</div><br />
In a wide-string build in the presence of MFC, then rather than causing a compilation error, the 10 will actually be converted to an instance of <span style="font-family: "Courier New",Courier,monospace;">CString</span>, via the conversion constructor taking a <span style="font-family: "Courier New",Courier,monospace;">TCHAR</span> argument!<br />
<br />
Obviously this is not desirable, particularly not for a diagnotic logging library! As of <a href="http://sourceforge.net/news/?group_id=141831&id=296069">1.0.1 beta 210</a>, there are compile-time constraints in the application layer function templates - <span style="font-family: "Courier New",Courier,monospace;">log()</span>, <span style="font-family: "Courier New",Courier,monospace;">log_DEBUG()</span>, etc. - that cause a compile error if any argument is of fundamental type.Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com2tag:blogger.com,1999:blog-7814929178759806750.post-9180654789219321172011-01-07T18:12:00.000-08:002019-10-17T21:39:34.113-07:00Pantheios::Extras::DiagUtil 0.1.1 (alpha 1)I've just released the first publicly available version - 0.1.1 (alpha 1) - of <b>Pantheios.Extras.DiagUtil</b>; details <a href="http://sourceforge.net/news/?group_id=141831&id=295987">here</a>.<br />
<br />
<br />
It allows a user to replace code such as:<br />
<br />
<pre> #if defined(_MSC_VER) && \
defined(_DEBUG)
<b># include <crtdbg.h></b>
#endif
int <b>main</b>(int argc, char** argv)
{
#if defined(_MSC_VER) && \
defined(_DEBUG)
_CrtMemState memState;
<b>_CrtMemCheckpoint</b>(&memState);
#endif
int result;
<b>. . . // main program logic</b> (which must assign to result)
#if defined(_MSC_VER) && \
defined(_DEBUG)
<b>_CrtMemDumpAllObjectsSince</b>(&memState);
#endif
return result;
}
</pre>
<br />
with:<br />
<br />
<pre> <b>#include <pantheios/extras/diagutil.hpp></b>
int <b>program</b>(int argc, char** argv)
{
<b>. . . // main program logic</b>
return EXIT_SUCCESS;
}
int main(int argc, char** argv)
{
return <b>pantheios::extras::diagutil::</b>
<b>main_leak_trace::invoke</b>(argc, argv, program);
}
</pre>
<br />
or, if your program is written in C, with:<br />
<br />
<pre> <b>#include <pantheios/extras/diagutil.h></b>
int <b>program</b>(int argc, char** argv)
{
<b>. . . // main program logic</b>
return EXIT_SUCCESS;
}
int main(int argc, char** argv)
{
return <b>pantheios_extras_diagutil_main_leak_trace_invoke</b>(
argc, argv, program);
}
</pre>
<br />
The immediate advantate is clear: substantially improved transparency in your application code. There are three secondary advantages: <br />
<ul>
<li>you do not need to explicitly conditionally include <b>crtdbg.h</b> </li>
<li>the library can be enhanced in the future to work with other compiler-extensions, without requiring any changes to your code </li>
<li>you do not have to avoid the use of <code>return</code> statements in your main program logic, and to remember to assign to <code>result</code> <br />
</li>
</ul>
<br />
More memory-tracing functionality will appear in forthcoming releases.Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-57981476311485801562011-01-06T23:16:00.000-08:002019-10-17T21:39:45.942-07:00Pantheios::Extras::Main 0.1.1 (alpha 1) releasedI've just released the first publicly available version - 0.1.1 (alpha 1) - of <b>Pantheios.Extras.Main</b>; details <a href="http://sourceforge.net/news/?group_id=141831&id=295942">here</a>.<br />
<br />
<br />
It allows a user to replace code such as:<br />
<br />
<pre>char const PROGRAM_NAME[] = "myprogram";
int main(int argc, char** argv)
{
<b>try</b>
{
. . . // program logic
return EXIT_SUCCESS;
}
<b>catch</b>(std::bad_alloc&)
{
pantheios::logputs(pantheios::alert, "out of memory");
fprintf(stderr, "%s: out of memory\n", PROGRAM_NAME);
}
<b>catch</b>(std::exception& x)
{
pantheios::log_CRITICAL(x);
fprintf(stderr, "%s: %s\n", PROGRAM_NAME, x.what());
}
<b>catch</b>(...)
{
pantheios::logputs(pantheios::emergency,
"unexpected unknown failure");
fprintf(stderr,
"%s: unexpected unknown failure\n",
PROGRAM_NAME);
}
return EXIT_FAILURE;
}
</pre>
<br />
with:<br />
<br />
<pre>char const PROGRAM_NAME[] = "myprogram";
int <b>program</b>(int argc, char** argv)
{
. . . // program logic
return EXIT_SUCCESS;
}
int main(int argc, char** argv)
{
return <b>pantheios::extras::main::invoke</b>(argc, argv,
program, PROGRAM_NAME);
}
</pre>
<br />
As discussed in the sixth instalment of <a href="http://quality-matters-to.us/">Quality Matters</a>, <a href="http://accu.org/index.php/journals/1706"><i>Exceptions for Practically-Unrecoverable Conditions</i></a>, without an exhaustive top-level try-catch statement, program robustness cannot be averred. <b>Pantheios.Extras.Main</b> let's you achieve that in a single statement.Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-34501861365033512272011-01-04T12:14:00.000-08:002011-01-04T12:14:54.910-08:00pantheios_be_file_flush()The newly released <a href="http://sourceforge.net/news/?group_id=141831&id=295841"><b>Pantheios</b> 1.0.1 beta 208</a> contains an enhancement to <a href="http://pantheios.sourceforge.net/doc/html/group__group____backend____stock__backends____file.html"><b>be.file</b></a>: the addition of a new API function <a href="http://pantheios.sourceforge.net/doc/html/group__group____backend____stock__backends____file.html#gfb4aba2a477e1364b8dadb2fe289685f"><span style="font-family: "Courier New",Courier,monospace;">pantheios_be_file_flush()</span></a>.<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"> int <b>pantheios_be_file_flush</b>(int backEndId);</span><br />
<br />
The function takes a single <span style="font-family: "Courier New",Courier,monospace;">int</span> argument, <span style="font-family: "Courier New",Courier,monospace;">backEndId</span>, representing the identifier of the specific be.file back-end instance to be flushed, or <a href="http://www.pantheios.org/doc/html/group__group____backend____stock__ids.html"><span style="font-family: "Courier New",Courier,monospace;">PANTHEIOS_BEID_ALL</span></a>, to apply to all be.file back-end instances.<br />
<br />
The function returns 0 on success, or a status code representing failure in one or more be.file back-end instances.Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-18039134026487963172011-01-04T12:11:00.000-08:002019-10-17T21:39:59.559-07:00Pantheios 1.0.1 beta 208 released<a href="http://sourceforge.net/news/?group_id=141831&id=295841"><b>Pantheios</b> 1.0.1 beta 208</a> is released. It contains:<br />
<br />
<ul>
<li>addition of new API function, <a href="http://pantheios.sourceforge.net/doc/html/group__group____backend____stock__backends____file.html#gfb4aba2a477e1364b8dadb2fe289685f"><span style="font-family: "courier new" , "courier" , monospace;">pantheios_be_file_flush()</span></a>, to <a href="http://pantheios.sourceforge.net/doc/html/group__group____backend____stock__backends____file.html"><b>be.file</b></a>.<b></b></li>
<li>fix of defect in <b>be.file</b>, whereby interpretation of date/time format specifiers in its file path - a feature added in <a href="https://sourceforge.net/news/?group_id=141831&id=292904">1.0.1 beta 197</a> - failed to add 1900 to year and 1 to month in be.file's </li>
<li>changes in names of status codes, removing word ERROR, and replacing with FAILURE.</li>
<li>removal of all remaining vestigial uses of magic numbers - principally -1 and -2 - from exception-catch clauses in core and several back-ends, and replacement with suitable status codes (e.g. <span style="font-family: "courier new" , "courier" , monospace;">PANTHEIOS_INIT_RC_UNSPECIFIED_FAILURE</span>).</li>
<li>non-functional enhancements to <b><a href="http://pantheios.sourceforge.net/doc/html/group__group____backend____stock__backends____N.html">be.N</a></b>, in preparation for new functionality in a forthcoming release</li>
<li>added a new FAQ item (#19), which explains how to use get Pantheios to compile the libraries when using Microsoft Visual C++'s <a href="http://msdn.microsoft.com/en-us/library/dh8che7s%28v=vs.80%29.aspx"><span style="font-family: "courier new" , "courier" , monospace;">-Zc:wchar_t-</span></a> flag.</li>
<li>removed <span style="font-family: "courier new" , "courier" , monospace;">-D_CRT_SECURE_NO_DEPRECATE</span> from all Visual C++ (8+) makefiles, since all Pantheios (and supporting <a href="http://stlsoft.org/"><b>STLSoft</b></a>) files are now compatible with Microsoft's "safe string" library.</li>
<li>added a new example, <b>example.cpp.util.strdup</b>, illustrating use of utility functions <span style="font-family: "courier new" , "courier" , monospace;">pantheios::util::strdup_throw()</span> and <span style="font-family: "courier new" , "courier" , monospace;">pantheios::util::strdup_nothrow()</span>.</li>
<li>removed all <b>include/pantheios/extras/*</b> files, which will (re-)appear in separate package distributions henceforth.</li>
</ul>
Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-56862300566708429512010-11-08T13:05:00.001-08:002010-11-08T13:05:49.252-08:00Wide String Shims for std::exceptionThe new release of <a href="http://www.stlsoft.org/"><b>STLSoft</b></a> supports seamless use of exceptions with <a href="http://www.pantheios.org/"><b>Pantheios</b></a> (and <a href="http://www.fastformat.org/"><b>FastFormat</b></a>) in wide-string builds; described on <a href="http://blog.stlsoft-musings.net/2010/11/wide-string-shims-for-stdexception.html">this post</a> on the <a href="http://blog.stlsoft-musings.net/"><b>STLSoft</b> project blog</a>.Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-14687403773545759142010-11-08T12:17:00.000-08:002010-11-08T12:17:24.077-08:00Pantheios 1.0.1 beta 198 released: new i and xi insertersThe <a href="http://sourceforge.net/news/?group_id=141831&id=293732">latest release</a> of <a href="http://www.pantheios.org/">Pantheios</a> includes two new inserters, <span style="font-family: "Courier New",Courier,monospace;">pantheios::i</span> and <span style="font-family: "Courier New",Courier,monospace;">pantheios::xi</span>. The former is a typedef for the <a href="http://www.pantheios.org/doc/html/classpantheios_1_1integer.html"><span style="font-family: "Courier New",Courier,monospace;">pantheios::integer</span></a> inserter class, and may be used interchangeably with it:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;"> #include <<b>pantheios/inserters/i.hpp</b>></div><div style="font-family: "Courier New",Courier,monospace;"><div style="font-family: "Courier New",Courier,monospace;"> #include <pantheios/pan.hpp></div><div style="font-family: "Courier New",Courier,monospace;"></div></div><div style="font-family: "Courier New",Courier,monospace;"> int n = 10; </div><br />
<div style="font-family: "Courier New",Courier,monospace;"> pan::log_DEBUG("i=", <b>pan::i</b>(n));</div><div style="font-family: "Courier New",Courier,monospace;"> pan::log_DEBUG("i=", <b>pan::i</b>(n, -10));</div><div style="font-family: "Courier New",Courier,monospace;"> pan::log_DEBUG("i=", <b>pan::i</b>(n, -10, pan::fmt::hex));</div><br />
produces the same output (and effectively the same binary) as:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;"> #include <<b>pantheios/inserters/integer.hpp</b>></div><div style="font-family: "Courier New",Courier,monospace;"><div style="font-family: "Courier New",Courier,monospace;"><div style="font-family: "Courier New",Courier,monospace;"> #include <pantheios/pan.hpp></div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div></div></div><div style="font-family: "Courier New",Courier,monospace;"> int n = 10; </div><br />
<div style="font-family: "Courier New",Courier,monospace;"> pan::log_DEBUG("i=", <b>pan::integer</b>(n));</div><div style="font-family: "Courier New",Courier,monospace;"><div style="font-family: "Courier New",Courier,monospace;"><div style="font-family: "Courier New",Courier,monospace;"> pan::log_DEBUG("i=", <b>pan::integer</b>(n, -10));</div><div style="font-family: "Courier New",Courier,monospace;"></div></div><div style="font-family: "Courier New",Courier,monospace;"><div style="font-family: "Courier New",Courier,monospace;"> pan::log_DEBUG("i=", <b>pan::integer</b>(n, -10, pan::fmt::hex));</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div></div></div>The latter is actually a new class, and is used specifically for inserting integers in hexadecimal form, optionally specifying minimum width:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;"> #include <<b>pantheios/inserters/xi.hpp</b>></div><div style="font-family: "Courier New",Courier,monospace;"><div style="font-family: "Courier New",Courier,monospace;"> #include <pantheios/pan.hpp></div></div><div style="font-family: "Courier New",Courier,monospace;"> int n = 16; </div><br />
<div style="font-family: "Courier New",Courier,monospace;"> pan::log_DEBUG("i=", <b>pan::xi</b>(n));</div><div style="font-family: "Courier New",Courier,monospace;"> pan::log_DEBUG("i=", <b>pan::xi</b>(n, -10));</div><br />
<br />
The (hopefully obvious) advantage to both these new inserter types is that they're more succinct. There are more to come ...Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-49558746574143400612010-11-02T14:38:00.000-07:002010-11-02T14:38:30.594-07:00User blogs about "Pantheios Basics"Just to let you know, <a href="http://dinhngocson.blogspot.com/">a user</a> has kindly posted a tutorial <a href="http://dinhngocson.blogspot.com/2010/11/pantheios-logging-library-basic.html"><i><b>Pantheios logging library - basic</b></i></a> blog entry, which covers the basics of obtaining, installing, and using the <a href="http://www.pantheios.org/"><b>Pantheios</b></a> library.<br />
<br />
I've just scanned it, and it looks like it covers quite a lot of stuff.<br />
<br />
<br />
I'll read it fully soon, and post any more relevant news.<br />
<br />
<br />
Thanks, <a href="http://dinhngocson.blogspot.com/">Son DN</a>!Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-14790909188515578832010-10-30T20:56:00.000-07:002010-10-30T20:58:00.554-07:00Choosing severity levelsA <a href="https://sourceforge.net/projects/pantheios/forums/forum/475314/topic/3915129">recent enquiry</a> on the <a href="https://sourceforge.net/projects/pantheios/forums/forum/475314"><b>Pantheios</b> Help Forum</a> requested guidance for what severity levels to use in what circumstances. Although I've a strong opinion on this, which I'll include in a series of articles on diagnostic logging that I'm currently preparing for <a href="http://www.drdobbs.com/">Dr. Dobbs</a> (and which I hope will see publication over Dec-Feb), I'm happy to volunteer the basic ideas here.<br />
<br />
Although Pantheios can be used with <i>any</i> range severity levels that fits into the <span style="font-family: "Courier New",Courier,monospace;">int</span> type - which usually means 32- or 64-bits, depending on platform - as it ships Pantheios defines <a href="http://www.pantheios.org/doc/html-old/group__group____core__library.html#g1757edae48cbe1ced9d83409d89a35e2">eight stock severity levels</a>, corresponding to the eight levels defined by <a href="http://en.wikipedia.org/wiki/Syslog">SysLog</a>, as follows:<br />
<br />
<br />
<table><tbody>
<tr><th>Syslog level</th><th>Pantheios level (C)</th><th>Pantheios level (C++)</th><th>Integer value</th></tr>
<tr><td>Emergency</td><td>PANTHEIOS_SEV_EMERGENCY</td><td>pantheios::emergency</td><td>0</td></tr>
<tr><td>Alert</td><td>PANTHEIOS_SEV_ALERT</td><td>pantheios::ealert</td><td>1</td></tr>
<tr><td>Critical</td><td>PANTHEIOS_SEV_CRITICAL</td><td>pantheios::critical</td><td>2</td></tr>
<tr><td>Error</td><td>PANTHEIOS_SEV_ERROR</td><td>pantheios::error</td><td>3</td></tr>
<tr><td>Warning</td><td>PANTHEIOS_SEV_WARNING</td><td>pantheios::warning</td><td>4</td></tr>
<tr><td>Notice</td><td>PANTHEIOS_SEV_NOTICE</td><td>pantheios::notice</td><td>5</td></tr>
<tr><td>Info</td><td>PANTHEIOS_SEV_INFO</td><td>pantheios::info</td><td>6</td></tr>
<tr><td>Debug</td><td>PANTHEIOS_SEV_DEBUG</td><td>pantheios::debug</td><td>7</td></tr>
</tbody></table><br />
Briefly, we treat these levels as follows. (Note, the terminology introduced in the <a href="http://www.synesis.com.au/publishing/quality-matters/exceptions-the-worst-form-of-error-handling-apart-from-all-the-others.html">first</a> and <a href="http://accu.org/index.php/journals/1706/">second</a> parts of my <a href="http://www.quality-matters-to.us/"><i>Quality Matters</i></a> column for <a href="http://www.accu.org/">ACCU</a>'s <a href="http://accu.org/index.php/journals/c78/">Overload</a> will be helpful in several instances.)<br />
<br />
<ul><li><b>Emergency</b> is used for (attempting to) record contract violations, i.e. the firing of an active runtime contract, indicating that the program is now behaving in contradiction to its design. According to <i><a href="http://www.breakingupthemonolith.com/glossary.html#principle-of-irrecoverability">the principle of irrecoverability</a></i>, a program in this state <i>must </i>immediately terminate, and thus it is possible to see an <b>emergency</b> level message being the last, or one of the last, messages in the diagnostic logging sequence of a program that has <i>faulted</i>.</li>
<li><b>Alert</b> is used for (attempting to) record practically-unrecoverable conditions, e.g. out of memory. It is customary to see an <b>alert</b> level message being the last, or one of the last, messages in the diagnostic logging sequence of a program that has ended processing in a <i>non-normative</i> manner.</li>
<li><b>Critical</b> and <b>error</b> are used for conditions that usually indicate that the <i>normative</i> behaviour of the program cannot be achieved. There is some ambiguity as to the exact distinction to draw between them, and I'm still in two minds about it. Obviously, <b>critical</b> is more severe, and may be associated with conditions more likely to result in program failure than does those designated as <b>error</b>.</li>
<li><b>Warning</b> is used for recording warning conditions.</li>
<li><b>Notice</b> is used for logging information that is to be displayed in "normal" operation, e.g. "database connection achieved"</li>
<li><b>Informational</b> is used for logging information that is useful when actively monitoring the health of a system, but that is not necessarily displayed as part of "normal" operation. Ideally it should be possible to turn on all logging of this level without exceeding the program's performance criteria.</li>
<li><b>Debug</b> is used for debugging statements. Note that one of the important advanges of using Pantheios is that its high efficiency means that you don't have to make decisions about eliding certain statements at compile-time; they can instead be made at runtime, which is appropriate. <i>Using Pantheios means eliminating </i><span style="font-family: "Courier New",Courier,monospace;">#ifdef DEBUG</span><i> from application code, forever!</i></li>
</ul>Note: a couple of commercial clients have engaged <a href="http://www.synesis.com.au/contact.html">us</a> to provide customisations that define more levels than these. Feel free to get in touch for this, or other, commercial customisations.<br />
<br />
I hope that's been helpful.Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-81509977155193080742010-10-18T13:49:00.000-07:002010-10-18T13:56:11.552-07:00Pantheios 1.0.1 beta 197 released: pantheios::integer inserter now more disciplined in width behaviour when hex formattingThe <a href="http://sourceforge.net/news/?group_id=141831&id=292904">latest release</a> of <a href="http://pantheios.org/">Pantheios</a> provides substantial reworking of the <a href="http://www.pantheios.org/doc/html/classpantheios_1_1integer.html"><span style="font-family: "Courier New",Courier,monospace;">pantheios::integer</span></a> inserter class, including how it handles minimum-width specifiers when formatting in hex. Previously, as a statement such as <br />
<br />
<div style="font-family: "Courier New",Courier,monospace;"> #include <pantheios/inserters/integer.hpp></div><div style="font-family: "Courier New",Courier,monospace;"><div style="font-family: "Courier New",Courier,monospace;"> #include <pantheios/pan.hpp></div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div></div><div style="font-family: "Courier New",Courier,monospace;"> int n = 0x13; <br />
pan::log_DEBUG("n=", pan::integer(n, 4, pan::fmt::hex));</div><br />
would have resulted in the output of a line such as:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">[old_int_hex.4312, 19/10/2010 7:38:53.062 AM; Debug]: n= 13</span><br />
<br />
With the (surprisingly involved!) changes in 1.0.1 beta 197, the line produces output such as:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">[old_int_hex.488, 19/10/2010 7:45:24.625 AM; Debug]: n=0x13</span><br />
<br />
Note the absence of the two spaces - between <span style="font-family: "Courier New",Courier,monospace;">n=</span> and <span style="font-family: "Courier New",Courier,monospace;">13</span> - that were previously associated with expanding <span style="font-family: "Courier New",Courier,monospace;">13</span> to a minimum width of four. (Anyone who's used <span style="font-family: "Courier New",Courier,monospace;">printf()</span> can guess how that came about.)<br />
<br />
Since these are only minimum widths, this change is unlikely to upset any log processing, but it's possible, so be advised.Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-18835047647538633792010-10-18T03:17:00.000-07:002010-10-18T13:27:41.153-07:00Pantheios 1.0.1 beta 197 released: be.file supports date/time in log file nameThe <a href="http://sourceforge.net/news/?group_id=141831&id=292904">latest release</a> of <a href="http://pantheios.org/">Pantheios</a> provides an enhancement to the <a href="http://pantheios.org/doc/html/group__group____backend____stock__backends____file.html">be.file</a> back-end, supporting current-date and/or current-time to form part of the log file-name. For example,<br />
<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;"> #include <pantheios/backends/bec.file.h></div><div style="font-family: "Courier New",Courier,monospace;"><br />
pantheios_be_file_setFilePath("test-%T-%D.log");</div><br />
The %T specifier is replaced by the current time, in the format HHMMSS. The %D specifier is replaced by the current date, in the format YYYYMMSS. If the function is called at, say, 7:22 am (and 10 seconds) on the 19th October 2010, the process will log to the file <span style="font-family: "Courier New",Courier,monospace;">test-20101019-072210.log</span>.<br />
<br />
(Note, as always, the following caveat: Pantheios' <a href="http://www.pantheios.org/doc/html/group__group____backend____stock__backends.html">stock back-ends</a> are intended for <a href="http://www.pantheios.org/tutorials_backends.html">tutorial</a> or simple program purposes. More sophisticated logging should be provided by having Pantheios delegate its transport to a fully-fledged logging library.)Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-30472694382391793312010-03-26T12:21:00.001-07:002010-03-26T12:21:09.411-07:00b 196 imminent: full wide-string supportTitle pretty much says it all. Am swamped - what's new - with commercial activities, but am hoping to get this out over the coming weekend.Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com0tag:blogger.com,1999:blog-7814929178759806750.post-57239587983212143322010-03-04T23:17:00.000-08:002010-03-04T23:17:21.781-08:00Pantheios 1.0.1 beta 195 released: enhanced pantheios::w2m inserterThe <a href="https://sourceforge.net/projects/pantheios/files/">latest release of Pantheios</a> provides enhanced flexibility for the <a href="http://pantheios.sourceforge.net/doc/html/classpantheios_1_1w2m.html"><span style="font-family: "Courier New",Courier,monospace;">pantheios::w2m</span></a> inserter class. As well as passing wide C-strings, as in:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;"> void f(wchar_t const* s)</div><div style="font-family: "Courier New",Courier,monospace;"> {</div><div style="font-family: "Courier New",Courier,monospace;"> pan::log_DEBUG("f(s=", <b>pan::w2m</b>(s), ")");</div><div style="font-family: "Courier New",Courier,monospace;"> . . .</div><div style="font-family: "Courier New",Courier,monospace;"> }</div><br />
the new facilities allow passing wide string class instances, as in:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;"> void f(std::string const& s)</div><div style="font-family: "Courier New",Courier,monospace;"> { <br />
</div><div style="font-family: "Courier New",Courier,monospace;"> pan::log_DEBUG("f(s=", <b>pan::w2m</b>(s), ")");</div><div style="font-family: "Courier New",Courier,monospace;"> . . .</div><div style="font-family: "Courier New",Courier,monospace;"> }</div><br />
<br />
and<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;"> void f(stlsoft::simple_wstring const& s)</div><div style="font-family: "Courier New",Courier,monospace;"> {<br />
</div><div style="font-family: "Courier New",Courier,monospace;"> pan::log_DEBUG("f(s=", <b>pan::w2m</b>(s), ")");</div><div style="font-family: "Courier New",Courier,monospace;"> . . .</div><div style="font-family: "Courier New",Courier,monospace;"> }</div><br />
<br />
Previously, the log statement would have to explicitly elicit the C-string pointer and the length, as in:<br />
<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;"> void f(stlsoft::simple_wstring const& s)</div><div style="font-family: "Courier New",Courier,monospace;"> {<br />
</div><div style="font-family: "Courier New",Courier,monospace;"> pan::log_DEBUG("f(s=", <b>pan::w2m</b>(s.data(), s.length()), ")");</div><div style="font-family: "Courier New",Courier,monospace;"> . . .</div><div style="font-family: "Courier New",Courier,monospace;"> }</div><br />
<br />
Obviously, this is far less expressive than the new facilities.Matt Wilsonhttp://www.blogger.com/profile/08032564940029177259noreply@blogger.com2