2017 © Pedro Peláez
 

yii2-extension yii2loggingutils

A very basic logging utility class. Designed to be used as a trait so you can use a default category depending on the class you are at .

image

rowasc/yii2loggingutils

A very basic logging utility class. Designed to be used as a trait so you can use a default category depending on the class you are at .

  • Sunday, September 6, 2015
  • by rowasc
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

yii2loggingutils

A very basic logging utility to help setup log categories from the controllers that "use" this trait/, (*1)

Usage

Configuration

In your Yii2's application config, under components=>log setup new logging categories you want to use, (*2)


'components' =>[ 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['info', 'error', 'warning', 'trace'], 'categories' => ['myawesomecategory'], 'logFile' => '@app/runtime/logs/myawesomecategory.log', 'maxFileSize' => 2048, 'maxLogFiles' => 10, 'logVars' => [] ]

Define your default log category for each class, so you have well defined categories to look into when something goes wrong.

namespace your\own\namespace;
use rowasc\components\Log;
class YourClass extends AnyClass {
    use Log;
    public $log_category="categoryOfYourLog";
    public function yourFancyFunction(){
        /** now use some loggers ! **/
        $this->_logError("Error that you really want to log " );
        $this->_logTrace($e);

    }
}

If you want to have a different category for some messages, just override the category when calling the logging functions.

namespace your\own\namespace;
use rowasc\components\Log;
class YourClass extends AnyClass {
    use Log;
    public $log_category="categoryOfYourLog";
    public function yourFancyFunction(){
        /** now use some loggers ! **/
        $this->_logError("Error that you really want to log " ,"myawesomecategory");
        $this->_logTrace($e,"myerrorcategory");

    }
}

The Versions

06/09 2015

dev-master

9999999-dev

A very basic logging utility class. Designed to be used as a trait so you can use a default category depending on the class you are at .

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romina Suarez

06/09 2015

1.0.1

1.0.1.0

A very basic logging utility class. Designed to be used as a trait so you can use a default category depending on the class you are at .

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romina Suarez