guide.txt

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· 文本 代码 · 共 924 行 · 第 1/3 页

TXT
924
字号
The Display Handler-------------------The Display handler simply prints the log events back to the browser.  Itrespects the ``error_prepend_string`` and ``error_append_string`` `errorhandling values`_ and is useful when `logging from standard error handlers`_.Configuration~~~~~~~~~~~~~+-------------------+-----------+---------------+---------------------------+| Parameter         | Type      | Default       | Description               |+===================+===========+===============+===========================+| ``error_prepend`` | String    | PHP INI value | This string will be       ||                   |           |               | prepended to the log      ||                   |           |               | output.                   |+-------------------+-----------+---------------+---------------------------+| ``error_append``  | String    | PHP INI value | This string will be       ||                   |           |               | appended to the log       ||                   |           |               | output.                   |+-------------------+-----------+---------------+---------------------------+.. _error handling values: http://www.php.net/errorfuncExample~~~~~~~::    $conf = array('error_prepend' => '<font color="#ff0000"><tt>',                  'error_append'  => '</tt></font>');    $logger = &Log::singleton('display', '', '', $conf, PEAR_LOG_DEBUG);    for ($i = 0; $i < 10; $i++) {        $logger->log("Log entry $i");    }The Error_Log Handler---------------------The Error_Log handler sends log events to PHP's `error_log()`_ function.Configuration~~~~~~~~~~~~~+-------------------+-----------+---------------+---------------------------+| Parameter         | Type      | Default       | Description               |+===================+===========+===============+===========================+| ``destination``   | String    | '' `(empty)`  | Optional destination value||                   |           |               | for `error_log()`_.  See  ||                   |           |               | `Error_Log Types`_ for    ||                   |           |               | more details.             |+-------------------+-----------+---------------+---------------------------+| ``extra_headers`` | String    | '' `(empty)`  | Additional headers to pass||                   |           |               | to the `mail()`_ function ||                   |           |               | when the                  ||                   |           |               | ``PEAR_LOG_TYPE_MAIL``    ||                   |           |               | type is specified.        |+-------------------+-----------+---------------+---------------------------+Error_Log Types~~~~~~~~~~~~~~~All of the available log types are detailed in the `error_log()`_ section ofthe PHP manual.  For your convenience, the Log package also defines thefollowing constants that can be used for the ``$name`` handler constructionparameter.+---------------------------+-----------------------------------------------+| Constant                  | Description                                   |+===========================+===============================================+| ``PEAR_LOG_TYPE_SYSTEM``  | Log events are sent to PHP's system logger,   ||                           | which uses the operating system's logging     ||                           | mechanism or a file (depending on the value   ||                           | of the `error_log configuration directive`_). |+---------------------------+-----------------------------------------------+| ``PEAR_LOG_TYPE_MAIL``    | Log events are sent via email to the address  ||                           | specified in the ``destination`` value.       |+---------------------------+-----------------------------------------------+| ``PEAR_LOG_TYPE_DEBUG``   | Log events are sent through PHP's debugging   ||                           | connection.  This will only work if           ||                           | `remote debugging`_ has been enabled.  The    ||                           | ``destination`` value is used to specify the  ||                           | host name or IP address of the target socket. |+---------------------------+-----------------------------------------------+| ``PEAR_LOG_TYPE_FILE``    | Log events will be appended to the file named ||                           | by the ``destination`` value.                 |+---------------------------+-----------------------------------------------+.. _error_log(): http://www.php.net/error_log.. _mail(): http://www.php.net/mail.. _error_log configuration directive: http://www.php.net/errorfunc#ini.error-log.. _remote debugging: http://www.php.net/install.configure#install.configure.enable-debuggerExample~~~~~~~::    $logger = &Log::singleton('error_log', PEAR_LOG_TYPE_SYSTEM, 'ident');    for ($i = 0; $i < 10; $i++) {        $logger->log("Log entry $i");    }The File Handler----------------The File handler writes log events to a text file using configurable stringformats.Configuration~~~~~~~~~~~~~+-------------------+-----------+---------------+---------------------------+| Parameter         | Type      | Default       | Description               |+===================+===========+===============+===========================+| ``append``        | Boolean   | True          | Should new log entries be ||                   |           |               | append to an existing log ||                   |           |               | file, or should the a new ||                   |           |               | log file overwrite an     ||                   |           |               | existing one?             |+-------------------+-----------+---------------+---------------------------+| ``mode``          | Integer   | 0644          | Octal representation of   ||                   |           |               | the log file's permissions||                   |           |               | mode.                     |+-------------------+-----------+---------------+---------------------------+| ``eol``           | String    | OS default    | The end-on-line character ||                   |           |               | sequence.                 |+-------------------+-----------+---------------+---------------------------+| ``lineFormat``    | String    | ``%1$s %2$s   | Log line format           ||                   |           | [%3$s] %4$s`` | specification.            |+-------------------+-----------+---------------+---------------------------+| ``timeFormat``    | String    | ``%b %d       | Time stamp format         ||                   |           | %H:%M:%S``    | (for strftime_).          |+-------------------+-----------+---------------+---------------------------+.. _strftime: http://www.php.net/strftimeExample~~~~~~~::    $conf = array('mode' => 0600, 'timeFormat' => '%X %x');    $logger = &Log::singleton('file', 'out.log', 'ident', $conf);    for ($i = 0; $i < 10; $i++) {        $logger->log("Log entry $i");    }The Mail Handler----------------The Mail handler aggregates a session's log events and sends them in the bodyof an email message using PHP's `mail()`_ function.Configuration~~~~~~~~~~~~~+-------------------+-----------+---------------+---------------------------+| Parameter         | Type      | Default       | Description               |+===================+===========+===============+===========================+| ``from``          | String    | sendmail_from | Value for the message's   ||                   |           | INI value     | ``From:`` header.         |+-------------------+-----------+---------------+---------------------------+| ``subject``       | String    | ``[Log_mail]  | Value for the message's   ||                   |           | Log message`` | ``Subject:`` header.      |+-------------------+-----------+---------------+---------------------------+| ``preamble``      | String    | `` `(empty)`  | Preamble for the message. |+-------------------+-----------+---------------+---------------------------+.. _mail(): http://www.php.net/mailExample~~~~~~~::    $conf = array('subject' => 'Important Log Events');    $logger = &Log::singleton('mail', 'webmaster@example.com', 'ident', $conf);    for ($i = 0; $i < 10; $i++) {        $logger->log("Log entry $i");    }The Null Handler----------------The Null handler simply consumes log events (akin to sending them to``/dev/null``).  `Log level masks`_ are respected, and the event will still besent to any registered `log observers`_.Example~~~~~~~::    $logger = &Log::singleton('null');    for ($i = 0; $i < 10; $i++) {        $logger->log("Log entry $i");    }The SQL (DB) Handler--------------------The SQL handler sends log events to a database using `PEAR's DB abstractionlayer`_.**Note:** Due to the constraints of the default database schema, the SQLhandler limits the length of the ``$ident`` string to sixteen (16) characters.This limit can be adjusted using the ``identLimit`` configuration parameter.The Log Table~~~~~~~~~~~~~The default SQL table used by this handler looks like this::    CREATE TABLE log_table (        id          INT NOT NULL,        logtime     TIMESTAMP NOT NULL,        ident       CHAR(16) NOT NULL,        priority    INT NOT NULL,        message     VARCHAR(200),        PRIMARY KEY (id)    );This is the "lowest common denominator" that should work across all SQLcompliant database.  You may want to make database- or site-specific changesto this schema to support your specific needs, however.  For example,`PostgreSQL`_ users may prefer to use a ``TEXT`` type for the ``message``field... _PostgreSQL: http://www.postgresql.org/Configuration~~~~~~~~~~~~~+-------------------+-----------+---------------+---------------------------+| Parameter         | Type      | Default       | Description               |+===================+===========+===============+===========================+| ``dsn``           | String    | '' `(empty)`  | A `Data Source Name`_.    ||                   |           |               | |required|                |+-------------------+-----------+---------------+---------------------------+| ``db``            | Object    | NULL          | An existing `DB`_ object. ||                   |           |               | If specified, this object ||                   |           |               | will be used, and ``dsn`` ||                   |           |               | will be ignored.          |+-------------------+-----------+---------------+---------------------------+| ``sequence``      | String    | ``log_id``    | The name of the sequence  ||                   |           |               | to use when generating    ||                   |           |               | unique event IDs.   Under ||                   |           |               | many databases, this will ||                   |           |               | be used as the name of    ||                   |           |               | the sequence table.       |+-------------------+-----------+---------------+---------------------------+| ``identLimit``    | Integer   | 16            | The maximum length of the ||                   |           |               | ``ident`` string.         ||                   |           |               | **Changing this value may ||                   |           |               | require updates to the SQL||                   |           |               | schema, as well.**        |+-------------------+-----------+---------------+---------------------------+The name of the database table to which the log entries will be written isspecified using the ``$name`` construction parameter (see `Configuring aHandler`_)... _DB: http://pear.php.net/package/DB.. _PEAR's DB abstraction layer: DB_.. _Data Source Name: http://pear.php.net/manual/en/package.database.db.intro-dsn.phpExamples~~~~~~~~Using a `Data Source Name`_ to create a new database connection::    $conf = array('dsn' => 'pgsql://jon@localhost+unix/logs');    $logger = &Log::singleton('sql', 'log_table', 'ident', $conf);    for ($i = 0; $i < 10; $i++) {        $logger->log("Log entry $i");    }Using an existing `DB`_ object::    require_once 'DB.php';    $db = &DB::connect('pgsql://jon@localhost+unix/logs');    $conf['db'] = $db;    $logger = &Log::singleton('sql', 'log_table', 'ident', $conf);    for ($i = 0; $i < 10; $i++) {        $logger->log("Log entry $i");    }The Sqlite Handler------------------:Author:        Bertrand Mansion:Contact:       bmansion@mamasam.comThe Sqlite handler sends log events to an Sqlite database using the `nativePHP sqlite functions`_.It is faster than `the SQL (DB) handler`_ because requests are made directlyto the database without using an abstraction layer.  It is also interesting tonote that Sqlite database files can be moved, copied, and deleted on yoursystem just like any other files, which makes log management easier.  Last butnot least, using a database to log your events allows you to use SQL queriesto create reports and statistics.When using a database and logging a lot of events, it is recommended to splitthe database into smaller databases.  This is allowed by Sqlite, and you canlater use the Sqlite `ATTACH`_ statement to query your log database filesglobally.If the database does not exist when the log is opened, sqlite will try tocreate it automatically. If the log table does not exist, it will also beautomatically created.  The table creation uses the following SQL request::    CREATE TABLE log_table (        id          INTEGER PRIMARY KEY NOT NULL,        logtime     NOT NULL,        ident       CHAR(16) NOT NULL,        priority    INT NOT NULL,        message    );

⌨️ 快捷键说明

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