<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Class Poco::NestedDiagnosticContext</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <meta name="author" content="Applied Informatics Software Engineering GmbH and Contributors"/> <meta name="publisher" content="Applied Informatics Software Engineering GmbH and Contributors"/> <meta name="copyright" content="Copyright (c) 2009, Applied Informatics Software Engineering GmbH and Contributors"/> <meta name="language" content="en"/> <meta name="date" content="2009-11-24"/> <meta name="generator" content="PocoDoc"/> <link rel="stylesheet" href="css/styles.css" type="text/css"/> </head> <body bgcolor="#ffffff" leftmargin="0" topmargin="0"> <div class="header"> <h1 class="namespace"><a href="Poco.html" class="namespace">Poco</a></h1> <h1 class="symbol">class NestedDiagnosticContext</h1> </div> <div class="body"> <p> <b>Library:</b> Foundation<br /> <b>Package:</b> Core<br /> <b>Header:</b> Poco/NestedDiagnosticContext.h</p> <h2>Description</h2> <div class="description"> <p>This class implements a Nested Diagnostic <a href="Poco.NestedDiagnosticContext.Context.html" title="struct Poco::NestedDiagnosticContext::Context">Context</a> (<a href="Poco.html#8776" title="Poco::NDC">NDC</a>), as described in Neil Harrison's article "Patterns for Logging Diagnostic Messages" in "Pattern Languages of Program Design 3" (Addison-Wesley). </p> <p>A <a href="Poco.html#8776" title="Poco::NDC">NDC</a> maintains a stack of context information, consisting of an informational string (e.g., a method name), as well as an optional source code line number and file name. NDCs are especially useful for tagging log messages with context information which is very helpful in a multithreaded server scenario. Every thread has its own private <a href="Poco.html#8776" title="Poco::NDC">NDC</a>, which is automatically created when needed and destroyed when the thread terminates. </p> <p>The <a href="Poco.NDCScope.html" title="class Poco::NDCScope">NDCScope</a> (or NDC::<a href="Poco.NestedDiagnosticContext.html#8747" title="Poco::NestedDiagnosticContext::Scope">Scope</a>) class can be used to automatically push information at the beginning of a scope, and to pop it at the end. The poco_ndc(info) macro augments the information with a source code line number and file name. </p> </div> <h2>Member Summary</h2> <p><b>Member Functions: </b><a href="Poco.NestedDiagnosticContext.html#8768" title="Poco::NestedDiagnosticContext::clear()">clear</a>, <a href="Poco.NestedDiagnosticContext.html#8769" title="Poco::NestedDiagnosticContext::current()">current</a>, <a href="Poco.NestedDiagnosticContext.html#8761" title="Poco::NestedDiagnosticContext::depth()">depth</a>, <a href="Poco.NestedDiagnosticContext.html#8763" title="Poco::NestedDiagnosticContext::dump()">dump</a>, <a href="Poco.NestedDiagnosticContext.html#8752" title="Poco::NestedDiagnosticContext::operator =()">operator =</a>, <a href="Poco.NestedDiagnosticContext.html#8760" title="Poco::NestedDiagnosticContext::pop()">pop</a>, <a href="Poco.NestedDiagnosticContext.html#8754" title="Poco::NestedDiagnosticContext::push()">push</a>, <a href="Poco.NestedDiagnosticContext.html#8762" title="Poco::NestedDiagnosticContext::toString()">toString</a></p> <h2>Types</h2> <h3><a name="8747">Scope</a></h3> <p class="decl">typedef <a href="Poco.NDCScope.html" title="class Poco::NDCScope">NDCScope</a> <a href="Poco.NestedDiagnosticContext.html#8747" title="Poco::NestedDiagnosticContext::Scope">Scope</a>;</p> <div class="description"> <p></p> </div> <h2>Constructors</h2> <h3><a name="8748">NestedDiagnosticContext</a></h3> <p class="decl"><a href="Poco.NestedDiagnosticContext.html" title="class Poco::NestedDiagnosticContext">NestedDiagnosticContext</a>();</p> <div class="description"> <p>Creates the <a href="Poco.NestedDiagnosticContext.html" title="class Poco::NestedDiagnosticContext">NestedDiagnosticContext</a>. </p> </div> <h3><a name="8749">NestedDiagnosticContext</a></h3> <p class="decl"><a href="Poco.NestedDiagnosticContext.html" title="class Poco::NestedDiagnosticContext">NestedDiagnosticContext</a>(<br /> const <a href="Poco.NestedDiagnosticContext.html" title="class Poco::NestedDiagnosticContext">NestedDiagnosticContext</a> & ctx<br />);</p> <div class="description"> <p>Copy constructor. </p> </div> <h2>Destructor</h2> <h3><a name="8751">~NestedDiagnosticContext</a></h3> <p class="decl">~<a href="Poco.NestedDiagnosticContext.html" title="class Poco::NestedDiagnosticContext">NestedDiagnosticContext</a>();</p> <div class="description"> <p>Destroys the <a href="Poco.NestedDiagnosticContext.html" title="class Poco::NestedDiagnosticContext">NestedDiagnosticContext</a>. </p> </div> <h2>Member Functions</h2> <h3><a name="8768">clear</a></h3> <p class="decl">void clear();</p> <div class="description"> <p>Clears the <a href="Poco.html#8776" title="Poco::NDC">NDC</a> stack. </p> </div> <h3><a name="8769">current</a> <img src="images/static.gif" alt="static" title="static" style="vertical-align:baseline;" border="0" /> </h3> <p class="decl">static <a href="Poco.NestedDiagnosticContext.html" title="class Poco::NestedDiagnosticContext">NestedDiagnosticContext</a> & current();</p> <div class="description"> <p>Returns the current thread's <a href="Poco.html#8776" title="Poco::NDC">NDC</a>. </p> </div> <h3><a name="8761">depth</a></h3> <p class="decl">int depth() const;</p> <div class="description"> <p>Returns the depth (number of contexts) of the stack. </p> </div> <h3><a name="8763">dump</a></h3> <p class="decl">void dump(<br /> std::ostream & ostr<br />) const;</p> <div class="description"> <p>Dumps the stack (including line number and filenames) to the given stream. The entries are delimited by a newline. </p> </div> <h3><a name="8765">dump</a></h3> <p class="decl">void dump(<br /> std::ostream & ostr,<br /> const std::string & delimiter<br />) const;</p> <div class="description"> <p>Dumps the stack (including line number and filenames) to the given stream. </p> </div> <h3><a name="8752">operator =</a></h3> <p class="decl"><a href="Poco.NestedDiagnosticContext.html" title="class Poco::NestedDiagnosticContext">NestedDiagnosticContext</a> & operator = (<br /> const <a href="Poco.NestedDiagnosticContext.html" title="class Poco::NestedDiagnosticContext">NestedDiagnosticContext</a> & ctx<br />);</p> <div class="description"> <p>Assignment operator. </p> </div> <h3><a name="8760">pop</a></h3> <p class="decl">void pop();</p> <div class="description"> <p>Pops the top-most context off the stack. </p> </div> <h3><a name="8754">push</a></h3> <p class="decl">void push(<br /> const std::string & info<br />);</p> <div class="description"> <p>Pushes a context (without line number and filename) onto the stack. </p> </div> <h3><a name="8756">push</a></h3> <p class="decl">void push(<br /> const std::string & info,<br /> int line,<br /> const char * filename<br />);</p> <div class="description"> <p>Pushes a context (including line number and filename) onto the stack. Filename must be a static string, such as the one produced by the __FILE__ preprocessor macro. </p> </div> <h3><a name="8762">toString</a></h3> <p class="decl">std::string toString() const;</p> <div class="description"> <p>Returns the stack as a string with entries delimited by colons. The string does not contain line numbers and filenames. </p> </div> <p class="footer">POCO C++ Libraries 1.3.6-all<br /> Copyright © 2009, <a href="http://pocoproject.org/" target="_blank">Applied Informatics Software Engineering GmbH and Contributors</a></p> </div> </body> </html>