title: How to use Boost.Log formatting expressions in custom formatting function
body: <p>I am trying to use a custom formatter with Boost.Log. The way I know how to do this is to call the <code>set_formatter</code> method of a sink giving it the address of a local function where the signature of the local function needs to be:</p>
  
  <pre><code>void my_formatter(boost::log::record_view const&amp; rec, boost::log::formatting_ostream&amp; strm)
  </code></pre>
  
  <p>In <code>my_formatter</code> I can use the Boost.Log extraction api to get the attribute values that I need. Once I get the values, I can output them to the <code>strm</code>. I want to do this so I can easily format some custom attributes stored in the record. But for other, more conventional Boost.Log attributes, I would like to continue to use the simple formatting expressions that are documented as keyword arguments to the <code>set_formatter</code> method. Is there a way to also use the keyword expressions in <code>my_formatter</code> custom function?</p>
  
  <p>For example:</p>
  
  <pre><code>void my_formatter(boost::log::record_view const&amp; rec, boost::log::formatting_ostream&amp; strm)
  {
      // here I can get the timestamp attribute and format its ticks value to the stream
      boost::log::value_ref&lt;boost::posix_time::ptime&gt; tstamp_ref =
          boost::log::extract&lt;boost::posix_time::ptime&gt;("TimeStamp", rec);
      const boost::posix_time::ptime&amp; timestamp = tstamp_ref.get();
  
      strm &lt;&lt; timestamp.time_of_day().ticks();
  }
  </code></pre>
  
  <p>Then given a sink, I can call</p>
  
  <pre><code>sink-&gt;set_formatter(&amp;my_formatter)
  </code></pre>
  
  <p>But Boost.Log gives me an elegant (almost magical) expression that I can use to set the formatter:</p>
  
  <pre><code>boost::log::formatter formatter =
      expr::stream
      &lt;&lt; expr::format_date_time&lt;boost::posix_time::ptime&gt;(
          "TimeStamp", "%Y/%m/%d, %H:%M:%S.%f, ");
  
  sink-&gt;set_formatter(formatter)
  </code></pre>
  
  <p>My question is: is there a way to use the formatter expression in my custom <code>my_formatter</code> function? </p>
  
  <p>Thanks!</p>