File: classwx_log_formatter.html

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (216 lines) | stat: -rw-r--r-- 14,291 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<!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>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>wxWidgets: wxLogFormatter Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="page_container">
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0" style="width: 100%;">
 <tbody>
 <tr>
  <td id="projectlogo">
    <a href="http://www.wxwidgets.org/" target="_new">
      <img alt="wxWidgets" src="logo.png"/>
    </a>
  </td>
  <td style="padding-left: 0.5em; text-align: right;">
   <span id="projectnumber">Version: 3.0.2</span>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- Generated by Doxygen 1.8.2 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Categories</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="classwx_log_formatter-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">wxLogFormatter Class Reference<div class="ingroups"><a class="el" href="group__group__class__logging.html">Logging</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p><code>#include &lt;wx/log.h&gt;</code></p>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p><a class="el" href="classwx_log_formatter.html" title="wxLogFormatter class is used to format the log messages.">wxLogFormatter</a> class is used to format the log messages. </p>
<p>It implements the default formatting and can be derived from to create custom formatters.</p>
<p>The default implementation formats the message into a string containing the time stamp, level-dependent prefix and the message itself.</p>
<p>To change it, you can derive from it and override its <a class="el" href="classwx_log_formatter.html#aca9b346cd05f61cc09ee67fe5e0cf072" title="This function creates the full log message string.">Format()</a> method. For example, to include the thread id in the log messages you can use </p>
<div class="fragment"><div class="line"><span class="keyword">class </span>LogFormatterWithThread : <span class="keyword">public</span> <a class="code" href="classwx_log_formatter.html" title="wxLogFormatter class is used to format the log messages.">wxLogFormatter</a></div>
<div class="line">{</div>
<div class="line">    <span class="keyword">virtual</span> <a class="code" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a> <a class="code" href="classwx_log_formatter.html#aca9b346cd05f61cc09ee67fe5e0cf072" title="This function creates the full log message string.">Format</a>(<a class="code" href="interface_2wx_2log_8h.html#ae0480cde4ec31e0f2e502e6e3082e74c" title="The type used to specify a log level.">wxLogLevel</a> level,</div>
<div class="line">                            <span class="keyword">const</span> <a class="code" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a>&amp; msg,</div>
<div class="line">                            <span class="keyword">const</span> <a class="code" href="classwx_log_record_info.html" title="Information about a log record (unit of the log output).">wxLogRecordInfo</a>&amp; info)<span class="keyword"> const</span></div>
<div class="line"><span class="keyword">    </span>{</div>
<div class="line">        <span class="keywordflow">return</span> <a class="code" href="classwx_string.html#addd9ccfa3ae2b7ab2d66bcbf034d0be0" title="This static function returns the string containing the result of calling Printf() with the passed par...">wxString::Format</a>(<span class="stringliteral">&quot;[%d] %s(%d) : %s&quot;</span>,</div>
<div class="line">            info.<a class="code" href="classwx_log_record_info.html#af7766219720d7215dcdef349d247916e" title="Id of the thread in which the message was generated.">threadId</a>, info.<a class="code" href="classwx_log_record_info.html#a91290266e065128e556e76a21e01dbd9" title="The name of the file where this log message was generated.">filename</a>, info.<a class="code" href="classwx_log_record_info.html#a1b5362167925e65dc65d59b2ea30a077" title="The line number at which this log message was generated.">line</a>, msg);</div>
<div class="line">    }</div>
<div class="line">};</div>
</div><!-- fragment --><p> And then associate it with <a class="el" href="classwx_log.html" title="wxLog class defines the interface for the log targets used by wxWidgets logging functions as explaine...">wxLog</a> instance using its SetFormatter(). Then, if you call:</p>
<div class="fragment"><div class="line"><a class="code" href="group__group__funcmacro__log.html#ga249358701f3c2d410088ddf7a61d8564" title="For all normal, informational messages.">wxLogMessage</a>(<a class="code" href="group__group__funcmacro__string.html#ga8a02b8875a521df57263a9e6f090f2d0" title="Macro to be used around all literal strings that should be translated.">_</a>(<span class="stringliteral">&quot;*** Application started ***&quot;</span>));</div>
</div><!-- fragment --><p>the log output could be something like:</p>
<pre class="fragment">    [7872] d:\testApp\src\testApp.cpp(85) : *** Application started ***
</pre><h2></h2>
<div><span class="lib">Library:</span>&#160;&#160;<span class="lib_text"><a class="el" href="page_libs.html#page_libs_wxbase">wxBase</a></span></div><div><span class="category">Category:</span>&#160;&#160;<span class="category_text"><a class="el" href="group__group__class__logging.html">Logging</a></span></div><dl class="section see"><dt>See Also</dt><dd><a class="el" href="overview_log.html">Logging Overview</a></dd></dl>
<dl class="section since"><dt>Since</dt><dd>2.9.4 </dd></dl>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a132ea746930dd66c2790845367cbd63e"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_log_formatter.html#a132ea746930dd66c2790845367cbd63e">wxLogFormatter</a> ()</td></tr>
<tr class="memdesc:a132ea746930dd66c2790845367cbd63e"><td class="mdescLeft">&#160;</td><td class="mdescRight">The default ctor does nothing.  <a href="#a132ea746930dd66c2790845367cbd63e"></a><br/></td></tr>
<tr class="separator:a132ea746930dd66c2790845367cbd63e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aca9b346cd05f61cc09ee67fe5e0cf072"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="classwx_string.html">wxString</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_log_formatter.html#aca9b346cd05f61cc09ee67fe5e0cf072">Format</a> (<a class="el" href="interface_2wx_2log_8h.html#ae0480cde4ec31e0f2e502e6e3082e74c">wxLogLevel</a> level, const <a class="el" href="classwx_string.html">wxString</a> &amp;msg, const <a class="el" href="classwx_log_record_info.html">wxLogRecordInfo</a> &amp;info) const </td></tr>
<tr class="memdesc:aca9b346cd05f61cc09ee67fe5e0cf072"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function creates the full log message string.  <a href="#aca9b346cd05f61cc09ee67fe5e0cf072"></a><br/></td></tr>
<tr class="separator:aca9b346cd05f61cc09ee67fe5e0cf072"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:a1d870f91f6df3deea1cd4bcf904b7f8e"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="classwx_string.html">wxString</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_log_formatter.html#a1d870f91f6df3deea1cd4bcf904b7f8e">FormatTime</a> (time_t time) const </td></tr>
<tr class="memdesc:a1d870f91f6df3deea1cd4bcf904b7f8e"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function formats the time stamp part of the log message.  <a href="#a1d870f91f6df3deea1cd4bcf904b7f8e"></a><br/></td></tr>
<tr class="separator:a1d870f91f6df3deea1cd4bcf904b7f8e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a132ea746930dd66c2790845367cbd63e"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">wxLogFormatter::wxLogFormatter </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The default ctor does nothing. </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="aca9b346cd05f61cc09ee67fe5e0cf072"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual <a class="el" href="classwx_string.html">wxString</a> wxLogFormatter::Format </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="interface_2wx_2log_8h.html#ae0480cde4ec31e0f2e502e6e3082e74c">wxLogLevel</a>&#160;</td>
          <td class="paramname"><em>level</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classwx_string.html">wxString</a> &amp;&#160;</td>
          <td class="paramname"><em>msg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classwx_log_record_info.html">wxLogRecordInfo</a> &amp;&#160;</td>
          <td class="paramname"><em>info</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>This function creates the full log message string. </p>
<p>Override it to customize the output string format.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">level</td><td>The level of this log record, e.g. <a class="el" href="interface_2wx_2log_8h.html#aacf1e0ade132ca66e9414ee658c94887a84701dd5e10b37607cd3b7237ee6f93d" title="a serious error, user must be informed about it">wxLOG_Error</a>. </td></tr>
    <tr><td class="paramname">msg</td><td>The log message itself. </td></tr>
    <tr><td class="paramname">info</td><td>All the other information (such as time, component, location...) associated with this log record.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The formated message.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>Time stamping is disabled for Visual C++ users in debug builds by default because otherwise it would be impossible to directly go to the line from which the log message was generated by simply clicking in the debugger window on the corresponding error message. If you wish to enable it, override <a class="el" href="classwx_log_formatter.html#a1d870f91f6df3deea1cd4bcf904b7f8e" title="This function formats the time stamp part of the log message.">FormatTime()</a>. </dd></dl>

</div>
</div>
<a class="anchor" id="a1d870f91f6df3deea1cd4bcf904b7f8e"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual <a class="el" href="classwx_string.html">wxString</a> wxLogFormatter::FormatTime </td>
          <td>(</td>
          <td class="paramtype">time_t&#160;</td>
          <td class="paramname"><em>time</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>This function formats the time stamp part of the log message. </p>
<p>Override this function if you need to customize just the time stamp.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">time</td><td>Time to format.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The formated time string, may be empty. </dd></dl>

</div>
</div>
</div><!-- contents -->

<address class="footer">
	<small>
		Generated on Thu Nov 27 2014 13:46:50 for wxWidgets by <a href="http://www.doxygen.org/index.html" target="_new">Doxygen</a> 1.8.2
	</small>
</address>
<script src="wxwidgets.js" type="text/javascript"></script>
</div><!-- #page_container -->
</body>
</html>