⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apache2::log.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 2 页
字号:
.el .IP "arg4: \f(CW$status\fR ( \f(CWAPR::Const status constant\fR )" 4.IX Item "arg4: $status ( APR::Const status constant )"The status code from the last command (similar to $! in perl), usually\&\f(CW\*(C`APR::Const constant\*(C'\fR or coming from anexception object..ie n .IP "arg5: @message ( strings \s-1ARRAY\s0 )" 4.el .IP "arg5: \f(CW@message\fR ( strings \s-1ARRAY\s0 )" 4.IX Item "arg5: @message ( strings ARRAY )"The log message(s).IP "ret: no return value" 4.IX Item "ret: no return value".PD 0.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPFor example:.PP.Vb 4\&  use Apache2::Const \-compile => qw(:log);\&  use APR::Const    \-compile => qw(ENOTIME SUCCESS);\&  $s\->log_serror(Apache2::Log::LOG_MARK, Apache2::Const::LOG_ERR,\&                 APR::Const::SUCCESS, "log_serror logging at err level");\&  \&  $s\->log_serror(Apache2::Log::LOG_MARK, Apache2::Const::LOG_DEBUG,\&                 APR::Const::ENOTIME, "debug print");.Ve.ie n .Sh """$s\->warn""".el .Sh "\f(CW$s\->warn\fP".IX Subsection "$s->warn".Vb 1\&  $s\->warn(@warnings);.Ve.PPis the same as:.PP.Vb 2\&  $s\->log_error(Apache2::Log::LOG_MARK, Apache2::Const::LOG_WARNING,\&                APR::Const::SUCCESS, @warnings).Ve.ie n .IP "obj: $s\fR ( \f(CW""Apache2::ServerRec object"" )" 4.el .IP "obj: \f(CW$s\fR ( \f(CWApache2::ServerRec object\fR )" 4.IX Item "obj: $s ( Apache2::ServerRec object )".PD 0.ie n .IP "arg1: @warnings ( strings \s-1ARRAY\s0 )" 4.el .IP "arg1: \f(CW@warnings\fR ( strings \s-1ARRAY\s0 )" 4.IX Item "arg1: @warnings ( strings ARRAY )".PDarray of warning strings.IP "ret: no return value" 4.IX Item "ret: no return value".PD 0.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPFor example:.PP.Vb 1\&  $s\->warn(\*(Aqroutine server warning\*(Aq);.Ve.SH "Request Logging Methods".IX Header "Request Logging Methods".ie n .Sh """$r\->log""".el .Sh "\f(CW$r\->log\fP".IX Subsection "$r->log"get a log handle which can be used to log messages of differentlevels..PP.Vb 1\&  $rlog = $r\->log;.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "ret: $rlog\fR ( \f(CW""Apache2::Log::Request"" object )" 4.el .IP "ret: \f(CW$rlog\fR ( \f(CWApache2::Log::Request\fR object )" 4.IX Item "ret: $rlog ( Apache2::Log::Request object )".PD\&\f(CW\*(C`Apache2::Log::Request\*(C'\fR object to be used with LogLevelmethods..IP "since: 2.0.00" 4.IX Item "since: 2.0.00".ie n .Sh """$r\->log_error""".el .Sh "\f(CW$r\->log_error\fP".IX Subsection "$r->log_error"just logs the supplied message (similar to\&\f(CW\*(C`$s\->log_error\*(C'\fR )..PP.Vb 1\&  $r\->log_error(@message);.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "arg1: @message ( strings \s-1ARRAY\s0 )" 4.el .IP "arg1: \f(CW@message\fR ( strings \s-1ARRAY\s0 )" 4.IX Item "arg1: @message ( strings ARRAY )".PDwhat to log.IP "ret: no return value" 4.IX Item "ret: no return value".PD 0.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPFor example:.PP.Vb 1\&  $r\->log_error("the request is about to end");.Ve.ie n .Sh """$r\->log_reason""".el .Sh "\f(CW$r\->log_reason\fP".IX Subsection "$r->log_reason"This function provides a convenient way to log errors in apreformatted way:.PP.Vb 2\&  $r\->log_reason($message);\&  $r\->log_reason($message, $filename);.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "arg1: $message ( string )" 4.el .IP "arg1: \f(CW$message\fR ( string )" 4.IX Item "arg1: $message ( string )".PDthe message to log.ie n .IP "opt arg2: $filename ( string )" 4.el .IP "opt arg2: \f(CW$filename\fR ( string )" 4.IX Item "opt arg2: $filename ( string )"where to report the error as coming from (e.g. \f(CW\*(C`_\|_FILE_\|_\*(C'\fR).IP "ret: no return value" 4.IX Item "ret: no return value".PD 0.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPFor example:.PP.Vb 1\&  $r\->log_reason("There is no enough data");.Ve.PPwill generate a log entry similar to the following:.PP.Vb 2\&  [Fri Sep 24 11:58:36 2004] [error] access to /someuri\&  failed for 127.0.0.1, reason: There is no enough data..Ve.ie n .Sh """$r\->log_rerror""".el .Sh "\f(CW$r\->log_rerror\fP".IX Subsection "$r->log_rerror"This function provides a fine control of when the message is logged,gives an access to built-in status codes..PP.Vb 1\&  $r\->log_rerror($file, $line, $level, $status, @message);.Ve.PParguments are identical to\&\f(CW\*(C`$s\->log_serror\*(C'\fR..IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PPFor example:.PP.Vb 4\&  use Apache2::Const \-compile => qw(:log);\&  use APR::Const    \-compile => qw(ENOTIME SUCCESS);\&  $r\->log_rerror(Apache2::Log::LOG_MARK, Apache2::Const::LOG_ERR,\&                 APR::Const::SUCCESS, "log_rerror logging at err level");\&  \&  $r\->log_rerror(Apache2::Log::LOG_MARK, Apache2::Const::LOG_DEBUG,\&                 APR::Const::ENOTIME, "debug print");.Ve.ie n .Sh """$r\->warn""".el .Sh "\f(CW$r\->warn\fP".IX Subsection "$r->warn".Vb 1\&  $r\->warn(@warnings);.Ve.PPis the same as:.PP.Vb 2\&  $r\->log_error(Apache2::Log::LOG_MARK, Apache2::Const::LOG_WARNING,\&                APR::Const::SUCCESS, @warnings).Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "arg1: @warnings ( strings \s-1ARRAY\s0 )" 4.el .IP "arg1: \f(CW@warnings\fR ( strings \s-1ARRAY\s0 )" 4.IX Item "arg1: @warnings ( strings ARRAY )".PDarray of warning strings.IP "ret: no return value" 4.IX Item "ret: no return value".PD 0.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPFor example:.PP.Vb 1\&  $r\->warn(\*(Aqroutine server warning\*(Aq);.Ve.SH "Other Logging Methods".IX Header "Other Logging Methods".Sh "LogLevel Methods".IX Subsection "LogLevel Methods"after getting the log handle with \f(CW\*(C`$s\->log\*(C'\fR or\&\f(CW\*(C`$r\->log\*(C'\fR, use one of the following methods(corresponding to the \f(CW\*(C`LogLevel\*(C'\fR levels):.PP.Vb 1\&  emerg(), alert(), crit(), error(), warn(), notice(), info(), debug().Ve.PPto control when messages should be logged:.PP.Vb 2\&  $s\->log\->emerg(@message);\&  $r\->log\->emerg(@message);.Ve.ie n .IP "obj: $slog ( server or request log handle )" 4.el .IP "obj: \f(CW$slog\fR ( server or request log handle )" 4.IX Item "obj: $slog ( server or request log handle )".PD 0.ie n .IP "arg1: @message ( strings \s-1ARRAY\s0 )" 4.el .IP "arg1: \f(CW@message\fR ( strings \s-1ARRAY\s0 )" 4.IX Item "arg1: @message ( strings ARRAY )".IP "ret: no return value" 4.IX Item "ret: no return value".IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPFor example if the \f(CW\*(C`LogLevel\*(C'\fR is \f(CW\*(C`error\*(C'\fR and the following code isexecuted:.PP.Vb 4\&  my $slog = $s\->log;\&  $slog\->debug("just ", "some debug info");\&  $slog\->warn(@warnings);\&  $slog\->crit("dying");.Ve.PPonly the last command's logging will be performed. This is because\&\fIwarn\fR, \fIdebug\fR and other logging command which are listed right to\&\fIerror\fR will be disabled..ie n .Sh """alert""".el .Sh "\f(CWalert\fP".IX Subsection "alert"See LogLevel Methods..ie n .Sh """crit""".el .Sh "\f(CWcrit\fP".IX Subsection "crit"See LogLevel Methods..ie n .Sh """debug""".el .Sh "\f(CWdebug\fP".IX Subsection "debug"See LogLevel Methods..ie n .Sh """emerg""".el .Sh "\f(CWemerg\fP".IX Subsection "emerg"See LogLevel Methods..ie n .Sh """error""".el .Sh "\f(CWerror\fP".IX Subsection "error"See LogLevel Methods..ie n .Sh """info""".el .Sh "\f(CWinfo\fP".IX Subsection "info"See LogLevel Methods..ie n .Sh """notice""".el .Sh "\f(CWnotice\fP".IX Subsection "notice"See LogLevel Methods..PPThough Apache treats \f(CW\*(C`notice()\*(C'\fR calls as special. The message isalways logged regardless the value of \f(CW\*(C`ErrorLog\*(C'\fR, unless the errorlog is set to use syslog. (For details see httpd\-2.0/server/log.c.).ie n .Sh """warn""".el .Sh "\f(CWwarn\fP".IX Subsection "warn"See LogLevel Methods..SH "General Functions".IX Header "General Functions".ie n .Sh """LOG_MARK""".el .Sh "\f(CWLOG_MARK\fP".IX Subsection "LOG_MARK"Though looking like a constant, this is a function, which returns alist of two items: \f(CW\*(C`(_\|_FILE_\|_, _\|_LINE_\|_)\*(C'\fR, i.e. the file and the linewhere the function was called from..PP.Vb 1\&  my ($file, $line) = Apache2::Log::LOG_MARK();.Ve.ie n .IP "ret1: $file ( string )" 4.el .IP "ret1: \f(CW$file\fR ( string )" 4.IX Item "ret1: $file ( string )".PD 0.ie n .IP "ret2: $line ( number )" 4.el .IP "ret2: \f(CW$line\fR ( number )" 4.IX Item "ret2: $line ( number )".IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPIt's mostly useful to be passed as the first argument to those loggingmethods, expecting the filename and the line number as the firstarguments (e.g., \f(CW\*(C`$s\->log_serror\*(C'\fR and\&\f(CW\*(C`$r\->log_rerror\*(C'\fR )..SH "Virtual Hosts".IX Header "Virtual Hosts"Code running from within a virtual host needs to be able to log intoits \f(CW\*(C`ErrorLog\*(C'\fR file, if different from the main log. Calling any ofthe logging methods on the \f(CW$r\fR and \f(CW$s\fR objects will do the loggingcorrectly..PPIf the core \f(CW\*(C`warn()\*(C'\fR is called, it'll be always logged to the mainlog file. Here is how to make it log into the vhost \fIerror_log\fR file.Let's say that we start with the following code:.PP.Vb 1\&  warn "the code is smoking";.Ve.IP "1." 4First, we need to use mod_perl's logging function, instead of\&\f(CW\*(C`CORE::warn\*(C'\fR.SpEither replace \f(CW\*(C`warn\*(C'\fR with \f(CW\*(C`Apache2::ServerRec::warn\*(C'\fR:.Sp.Vb 2\&  use Apache2::Log ();\&  Apache2::ServerRec::warn("the code is smoking");.Ve.Spor import it into your code:.Sp.Vb 2\&  use Apache2::ServerRec qw(warn); # override warn locally\&  warn "the code is smoking";.Ve.Spor override \f(CW\*(C`CORE::warn\*(C'\fR:.Sp.Vb 3\&  use Apache2::Log ();\&  *CORE::GLOBAL::warn = \e&Apache2::ServerRec::warn;\&  warn "the code is smoking";.Ve.SpAvoid using the latter suggestion, since it'll affect all the coderunning on the server, which may break things. Of course you canlocalize that as well:.Sp.Vb 3\&  use Apache2::Log ();\&  local *CORE::GLOBAL::warn = \e&Apache2::ServerRec::warn;\&  warn "the code is smoking";.Ve.SpChances are that you need to make the internal Perl warnings go intothe vhost's \fIerror_log\fR file as well. Here is how to do that:.Sp.Vb 3\&  use Apache2::Log ();\&  local $SIG{_\|_WARN_\|_} = \e&Apache2::ServerRec::warn;\&  eval q[my $x = "aaa" + 1;]; # this issues a warning.Ve.SpNotice that it'll override any previous setting you may have had,disabling modules like \f(CW\*(C`CGI::Carp\*(C'\fR which also use \f(CW$SIG{_\|_WARN_\|_}\fR.IP "2." 4Next we need to figure out how to get hold of the vhost's serverobject..SpInside \s-1HTTP\s0 request handlers this is possible via\&\f(CW\*(C`Apache2\->request|docs::2.0::api::Apache2::RequestUtil/C_request_\*(C'\fR. Whichrequires either \f(CW\*(C`PerlOptions+GlobalRequest\*(C'\fRsetting or can be also done at runtime if \f(CW$r\fR is available:.Sp.Vb 5\&  use Apache2::RequestUtil ();\&  sub handler {\&      my $r = shift;\&      Apache2::RequestUtil\->request($r);\&      ....Ve.SpOutside \s-1HTTP\s0 handlers at the moment it is not possible, to get hold ofthe vhost's \fIerror_log\fR file. This shouldn't be a problem for thecode that runs only under mod_perl, since the always available \f(CW$s\fRobject can invoke a plethora of methods supplied by\&\f(CW\*(C`Apache2::Log\*(C'\fR. This is only a problem for modules, which are supposedto run outside mod_perl as well..Sp\&\s-1META:\s0 To solve this we think to introduce 'PerlOptions +GlobalServer',a big brother for 'PerlOptions +GlobalRequest', which will be set inmodperl_hook_pre_connection..SH "Unsupported API".IX Header "Unsupported API"\&\f(CW\*(C`Apache2::Log\*(C'\fR also provides auto-generated Perl interface for a fewother methods which aren't tested at the moment and therefore their\&\s-1API\s0 is a subject to change. These methods will be finalized later as aneed arises. If you want to rely on any of the following methodsplease contact the the mod_perl development mailinglist so we can help each other take the steps necessaryto shift the method to an officially supported \s-1API\s0..ie n .Sh """log_pid""".el .Sh "\f(CWlog_pid\fP".IX Subsection "log_pid"\&\s-1META:\s0 what is this method good for? it just calls getpid and logsit. In any case it has nothing to do with the logging \s-1API\s0. And it usesstatic variables, it probably shouldn't be in the Apache public \s-1API\s0..PPLog the current pid.PP.Vb 1\&  Apache2::Log::log_pid($pool, $fname);.Ve.ie n .IP "obj: $p\fR ( \f(CW""APR::Pool object"" )" 4.el .IP "obj: \f(CW$p\fR ( \f(CWAPR::Pool object\fR )" 4.IX Item "obj: $p ( APR::Pool object )"The pool to use for logging.ie n .IP "arg1: $fname ( file path )" 4.el .IP "arg1: \f(CW$fname\fR ( file path )" 4.IX Item "arg1: $fname ( file path )"The name of the file to log to.IP "ret: no return value" 4.IX Item "ret: no return value".PD 0.IP "since: subject to change" 4.IX Item "since: subject to change".PD.SH "See Also".IX Header "See Also"mod_perl 2.0 documentation..SH "Copyright".IX Header "Copyright"mod_perl 2.0 and its core modules are copyrighted underThe Apache Software License, Version 2.0..SH "Authors".IX Header "Authors"The mod_perl development team and numerouscontributors.

⌨️ 快捷键说明

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