system system.base system.caching system.caching.dependencies system.collections system.console system.db system.db.ar system.db.schema system.db.schema.mssql system.db.schema.mysql system.db.schema.oci system.db.schema.pgsql system.db.schema.sqlite system.i18n system.i18n.gettext system.logging system.utils system.validators system.web system.web.actions system.web.auth system.web.filters system.web.helpers system.web.renderers system.web.services system.web.widgets system.web.widgets.captcha system.web.widgets.pagers

CDbLogRoute

system.logging
继承 class CDbLogRoute » CLogRoute » CComponent
可用自 1.0
版本 $Id$
CDbLogRoute stores log messages in a database table.

To specify the database table for storing log messages, set logTableName as the name of the table and specify connectionID to be the ID of a CDbConnection application component. If they are not set, a SQLite3 database named 'log-YiiVersion.db' will be created and used under the application runtime directory.

公共属性

隐藏继承的属性

属性类型描述被定义在
autoCreateLogTable boolean whether the log DB table should be automatically created if not exists. CDbLogRoute
categories string list of categories separated by comma or space. CLogRoute
connectionID string the ID of CDbConnection application component. CDbLogRoute
enabled boolean whether to enable this log route. CLogRoute
filter mixed the additional filter (e. CLogRoute
levels string list of levels separated by comma or space. CLogRoute
logTableName string the name of the DB table that stores log content. CDbLogRoute

受保护的属性

隐藏继承的属性

属性类型描述被定义在
dbConnection CDbConnection the DB connection instance CDbLogRoute

公共方法

隐藏继承的方法

方法描述被定义在
__call() Calls the named method which is not a class method. CComponent
__destruct() Destructor. CDbLogRoute
__get() Returns a property value, an event handler list or a behavior based on its name. CComponent
__isset() Checks if a property value is null. CComponent
__set() Sets value of a component property. CComponent
__unset() Sets a component property to be null. CComponent
asa() Returns the named behavior object. CComponent
attachBehavior() Attaches a behavior to this component. CComponent
attachBehaviors() Attaches a list of behaviors to the component. CComponent
attachEventHandler() Attaches an event handler to an event. CComponent
canGetProperty() Determines whether a property can be read. CComponent
canSetProperty() Determines whether a property can be set. CComponent
collectLogs() Retrieves filtered log messages from logger for further processing. CLogRoute
detachBehavior() Detaches a behavior from the component. CComponent
detachBehaviors() Detaches all behaviors from the component. CComponent
detachEventHandler() Detaches an existing event handler. CComponent
disableBehavior() Disables an attached behavior. CComponent
disableBehaviors() Disables all behaviors attached to this component. CComponent
enableBehavior() Enables an attached behavior. CComponent
enableBehaviors() Enables all behaviors attached to this component. CComponent
getEventHandlers() Returns the list of attached event handlers for an event. CComponent
hasEvent() Determines whether an event is defined. CComponent
hasEventHandler() Checks whether the named event has attached handlers. CComponent
hasProperty() Determines whether a property is defined. CComponent
init() Initializes the route. CDbLogRoute
raiseEvent() Raises an event. CComponent

受保护的方法

隐藏继承的方法

方法描述被定义在
createLogTable() Creates the DB table for storing log messages. CDbLogRoute
formatLogMessage() Formats a log message given different fields. CLogRoute
getDbConnection() CDbLogRoute
processLogs() Stores log messages into database. CDbLogRoute

属性详情

autoCreateLogTable 属性
public boolean $autoCreateLogTable;

whether the log DB table should be automatically created if not exists. Defaults to true.

参见

connectionID 属性
public string $connectionID;

the ID of CDbConnection application component. If not set, a SQLite database will be automatically created and used. The SQLite database file is protected/runtime/log-YiiVersion.db.

dbConnection 属性 只读

the DB connection instance

logTableName 属性
public string $logTableName;

the name of the DB table that stores log content. Defaults to 'YiiLog'. If autoCreateLogTable is false and you want to create the DB table manually by yourself, you need to make sure the DB table is of the following structure:

 (
	id       INTEGER NOT NULL PRIMARY KEY,
	level    VARCHAR(128),
	category VARCHAR(128),
	logtime  INTEGER,
	message  TEXT
  )
Note, the 'id' column must be created as an auto-incremental column. In MySQL, this means it should be id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY; In PostgreSQL, it is id SERIAL PRIMARY KEY.

方法详情

__destruct() 方法
public void __destruct()

Destructor. Disconnect the db connection.

createLogTable() 方法
protected void createLogTable(CDbConnection $db, string $tableName)
$db CDbConnection the database connection
$tableName string the name of the table to be created

Creates the DB table for storing log messages.

getDbConnection() 方法
protected CDbConnection getDbConnection()
{return} CDbConnection the DB connection instance

init() 方法
public void init()

Initializes the route. This method is invoked after the route is created by the route manager.

processLogs() 方法
protected void processLogs(array $logs)
$logs array list of log messages

Stores log messages into database.