debugfile.html

来自「perl教程」· HTML 代码 · 共 176 行

HTML
176
字号
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>LWP::DebugFile - routines for tracing/debugging LWP</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>

<body>

<script>writelinks('__top__',2);</script>
<h1><a>LWP::DebugFile - routines for tracing/debugging LWP</a></h1>
<p><a name="__index__"></a></p>

<!-- INDEX BEGIN -->

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#synopsis">SYNOPSIS</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<li><a href="#options">OPTIONS</a></li>
	<li><a href="#output_file_naming">OUTPUT FILE NAMING</a></li>
	<li><a href="#environment">ENVIRONMENT</a></li>
	<li><a href="#implementation_notes">IMPLEMENTATION NOTES</a></li>
	<li><a href="#see_also">SEE ALSO</a></li>
	<li><a href="#copyright_and_disclaimers">COPYRIGHT AND DISCLAIMERS</a></li>
	<li><a href="#author">AUTHOR</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>LWP::DebugFile - routines for tracing/debugging LWP</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<p>If you want to see just what LWP is doing when your program calls it,
add this to the beginning of your program's source:</p>
<pre>
  <span class="keyword">use</span> <span class="variable">LWP::DebugFile</span><span class="operator">;</span>
</pre>
<p>For even more verbose debug output, do this instead:</p>
<pre>
  <span class="keyword">use</span> <span class="variable">LWP::DebugFile</span> <span class="operator">(</span><span class="string">'+'</span><span class="operator">);</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>This module is like LWP::Debug in that it allows you to see what your
calls to LWP are doing behind the scenes.  But it is unlike
<a href="../../lib/LWP/Debug.html">LWP::Debug</a> in that it sends the output to a file, instead
of to STDERR (as LWP::Debug does).</p>
<p>
</p>
<hr />
<h1><a name="options">OPTIONS</a></h1>
<p>The options you can use in <code>use LWP::DebugFile (options)</code> are the
same as the <strong>non-exporting</strong> options available from <code>use LWP::Debug
(options)</code>.  That is, you can do things like this:</p>
<pre>
  <span class="keyword">use</span> <span class="variable">LWP::DebugFile</span> <span class="string">qw(+)</span><span class="operator">;</span>
  <span class="keyword">use</span> <span class="variable">LWP::Debug</span> <span class="string">qw(+ -conns)</span><span class="operator">;</span>
  <span class="keyword">use</span> <span class="variable">LWP::Debug</span> <span class="string">qw(trace)</span><span class="operator">;</span>
</pre>
<p>The meanings of these are explained in the
<a href="../../lib/LWP/Debug.html">documentation for LWP::Debug</a>.
The only differences are that by default, LWP::DebugFile has <code>cons</code>
debugging on, ad that (as mentioned earlier), only <code>non-exporting</code>
options are available.  That is, you <strong>can't</strong> do this:</p>
<pre>
  <span class="keyword">use</span> <span class="variable">LWP::DebugFile</span> <span class="string">qw(trace)</span><span class="operator">;</span> <span class="comment"># wrong</span>
</pre>
<p>You might expect that to export LWP::Debug's <code>trace()</code> function,
but it doesn't work -- it's a compile-time error.</p>
<p>
</p>
<hr />
<h1><a name="output_file_naming">OUTPUT FILE NAMING</a></h1>
<p>If you don't do anything, the output file (where all the LWP debug/trace
output goes) will be in the current directory, and will be named like
<em>lwp_3db7aede_b93.log</em>, where <em>3db7aede</em> is <a href="../../lib/Pod/perlvar.html#item___t"><code>$^T</code></a> expressed in hex,
and <code>b93</code> is <a href="../../lib/Pod/perlvar.html#item___"><code>$$</code></a> expressed in hex.  Presumably this is a
unique-for-all-time filename!</p>
<p>If you don't want the files to go in the current directory, you
can set <code>$LWP::DebugFile::outpath</code> before you load the LWP::DebugFile
module:</p>
<pre>
  <span class="keyword">BEGIN</span> <span class="operator">{</span> <span class="variable">$LWP::DebugFile::outpath</span> <span class="operator">=</span> <span class="string">'/tmp/crunk/'</span> <span class="operator">}</span>
  <span class="keyword">use</span> <span class="variable">LWP::DebugFile</span><span class="operator">;</span>
</pre>
<p>Note that you must end the value with a path separator (&quot;/&quot; in this
case -- under MacPerl it would be &quot;:&quot;).  With that set, you will
have output files named like <em>/tmp/crunk/lwp_3db7aede_b93.log</em>.</p>
<p>If you want the LWP::DebugFile output to go a specific filespec (instead
of just a uniquely named file, in whatever directory), instead set the
variable <code>$LWP::DebugFile::outname</code>, like so:</p>
<pre>
  <span class="keyword">BEGIN</span> <span class="operator">{</span> <span class="variable">$LWP::DebugFile::outname</span> <span class="operator">=</span> <span class="string">'/home/mojojojo/lwp.log'</span> <span class="operator">}</span>
  <span class="keyword">use</span> <span class="variable">LWP::DebugFile</span><span class="operator">;</span>
</pre>
<p>In that case, <code>$LWP::DebugFile::outpath</code> isn't consulted at all, and
output is always written to the file <em>/home/mojojojo/lwp.log</em>.</p>
<p>Note that the value of <code>$LWP::DebugFile::outname</code> doesn't need to
be an absolute filespec.  You can do this:</p>
<pre>
  <span class="keyword">BEGIN</span> <span class="operator">{</span> <span class="variable">$LWP::DebugFile::outname</span> <span class="operator">=</span> <span class="string">'lwp.log'</span> <span class="operator">}</span>
  <span class="keyword">use</span> <span class="variable">LWP::DebugFile</span><span class="operator">;</span>
</pre>
<p>In that case, output goes to a file named <em>lwp.log</em> in the current
directory -- specifically, whatever directory is current when
LWP::DebugFile is first loaded. <code>$LWP::DebugFile::outpath</code> is still not
consulted -- its value is used only if <code>$LWP::DebugFile::outname</code>
isn't set.</p>
<p>
</p>
<hr />
<h1><a name="environment">ENVIRONMENT</a></h1>
<p>If you set the environment variables <code>LWPDEBUGPATH</code> or 
<code>LWPDEBUGFILE</code>, their values will be used in initializing the
values of <code>$LWP::DebugFile::outpath</code>
and <code>$LWP::DebugFile::outname</code>.</p>
<p>That is, if you have <code>LWPDEBUGFILE</code> set to <em>/home/mojojojo/lwp.log</em>,
then you can just start out your program with:</p>
<pre>
  <span class="keyword">use</span> <span class="variable">LWP::DebugFile</span><span class="operator">;</span>
</pre>
<p>and it will act as if you had started it like this:</p>
<pre>
  <span class="keyword">BEGIN</span> <span class="operator">{</span> <span class="variable">$LWP::DebugFile::outname</span> <span class="operator">=</span> <span class="string">'/home/mojojojo/lwp.log'</span> <span class="operator">}</span>
  <span class="keyword">use</span> <span class="variable">LWP::DebugFile</span><span class="operator">;</span>
</pre>
<p>
</p>
<hr />
<h1><a name="implementation_notes">IMPLEMENTATION NOTES</a></h1>
<p>This module works by subclassing <code>LWP::Debug</code>, (notably inheriting its
<a href="../../lib/Pod/perlfunc.html#item_import"><code>import</code></a>). It also redefines <code>&amp;LWP::Debug::conns</code> and
<code>&amp;LWP::Debug::_log</code> to make for output that is a little more verbose,
and friendlier for when you're looking at it later in a log file.</p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="../../lib/LWP/Debug.html">the LWP::Debug manpage</a></p>
<p>
</p>
<hr />
<h1><a name="copyright_and_disclaimers">COPYRIGHT AND DISCLAIMERS</a></h1>
<p>Copyright (c) 2002 Sean M. Burke.</p>
<p>This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.</p>
<p>This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.</p>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>Sean M. Burke <code>sburke@cpan.org</code></p>

</body>

</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?