Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added documentation for new negating categories feature #1497

Merged
merged 5 commits into from

4 participants

acorncom Alexander Makarov Maurizio Domba Cerin Qiang Xue
acorncom

Doc addition for pull request #1376

docs/guide/topics.logging.txt
((5 lines not shown))
+we can prevent certain categories from appearing in our logs:
+
+~~~
+[php]
+array(
+ ......
+ 'preload'=>array('log'),
+ 'components'=>array(
+ ......
+ 'log'=>array(
+ 'class'=>'CLogRouter',
+ 'routes'=>array(
+ array(
+ 'class'=>'CFileLogRoute',
+ 'levels'=>'trace, info',
+ 'categories'=>'!system.CModule, system.*',
Qiang Xue Owner

We are not using this syntax. We use 'except' property instead.

Maurizio Domba Cerin Collaborator
mdomba added a note

As Qiang noted instead of ! there should the an except property with a list of categories that will be prevented.

As for the example to be short and concise IMO you can start with the 'routes' => array - no need for all those lines before that.

In addition if you have time, revisit the CLogRoute.php -> the description of $categories remained Defaults to empty, ... -> should be changed to Defaults to empty array(), ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
acorncom

Ok, just tweaked those bugs with my pull request. Thoughts?

Maurizio Domba Cerin

as exclude is used, there is no need for the ! char

Meant to get that the last time :-/

docs/guide/topics.logging.txt
@@ -89,6 +89,31 @@ category starts with `system.` are saved. The second route is
[CEmailLogRoute] which sends messages to the specified email addresses.
Only messages whose level is `error` or `warning` are sent.
+In a more advanced example (using an exclude feature available in Yii 1.1.13+),
+we can prevent certain categories from appearing in our logs:
+
+~~~
+[php]
+ 'routes'=>array(
+ array(
+ 'class'=>'CFileLogRoute',
+ 'levels'=>'trace, info',
+ 'categories'=>'system.*',
+ 'exclude'=>'system.CModule', // shows everything from system except CModule level logs
Alexander Makarov Collaborator
samdark added a note

Logs with category system.CModule exactly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
docs/guide/topics.logging.txt
((4 lines not shown))
+In a more advanced example (using an exclude feature available in Yii 1.1.13+),
+we can prevent certain categories from appearing in our logs:
+
+~~~
+[php]
+ 'routes'=>array(
+ array(
+ 'class'=>'CFileLogRoute',
+ 'levels'=>'trace, info',
+ 'categories'=>'system.*',
+ 'exclude'=>'system.CModule', // shows everything from system except CModule level logs
+ ),
+ array(
+ 'class'=>'CEmailLogRoute',
+ 'levels'=>'error, warning',
+ 'exclude'=>'system.CModule.*' // Will show everything except any CModule logs
Alexander Makarov Collaborator
samdark added a note

Logs with category system.CModule.anything?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
acorncom

Cleaned this up to clarify things further.

@samdark per your questions, just went back and looked over the code in more detail. Per the highlighted lines 194-198, it looks like we're excluding in the exact same way we're handling categories. So it does look like we'd be able to leave out system.CModule.anything Would you agree?

Alexander Makarov samdark was assigned
Alexander Makarov
Collaborator

My remark was about using system.CModule w/o .*.

Alexander Makarov
Collaborator

Now everything looks good to me. Will merge it. Thanks for working on it.

Alexander Makarov samdark merged commit e973b5d into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 21 additions and 1 deletion.
  1. +19 −0 docs/guide/topics.logging.txt
  2. +2 −1  framework/logging/CLogRoute.php
19 docs/guide/topics.logging.txt
View
@@ -89,6 +89,25 @@ category starts with `system.` are saved. The second route is
[CEmailLogRoute] which sends messages to the specified email addresses.
Only messages whose level is `error` or `warning` are sent.
+In a more advanced example (using an exclude feature available in Yii 1.1.13+),
+we can prevent certain categories from appearing in our logs:
+
+~~~
+[php]
+ 'routes'=>array(
+ array(
+ 'class'=>'CEmailLogRoute',
+ 'levels'=>'error, warning',
+ 'exclude'=>'system.CModule.*' // Will email everything except any CModule logs
+ 'emails'=>'admin@example.com',
+ ),
+ array(
+ 'class'=>'CWebLogRoute',
+ 'categories'=>'system.db.*',
+ 'exclude'=>'system.db.ar.*', // shows all db level logs but nothing in the ar category
+ ),
+~~~
+
The following log routes are available in Yii:
- [CDbLogRoute]: saves messages in a database table.
3  framework/logging/CLogRoute.php
View
@@ -40,11 +40,12 @@
public $levels='';
/**
* @var mixed array of categories, or string list separated by comma or space.
- * Defaults to empty, meaning all categories.
+ * Defaults to empty array, meaning all categories.
*/
public $categories=array();
/**
* @var mixed array of categories, or string list separated by comma or space, to EXCLUDE from logs.
+ * Defaults to empty array, meaning no categories are excluded.
* This will exclude any categories after $categories has been ran
*/
public $except=array();
Something went wrong with that request. Please try again.