LogTrait.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  10. * @link http://cakephp.org CakePHP(tm) Project
  11. * @since CakePHP(tm) v 3.0.0
  12. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  13. */
  14. namespace Cake\Log;
  15. /**
  16. * A trait providing an object short-cut method
  17. * to logging.
  18. *
  19. */
  20. trait LogTrait {
  21. /**
  22. * Convenience method to write a message to Log. See Log::write()
  23. * for more information on writing to logs.
  24. *
  25. * @param string $msg Log message
  26. * @param integer $type Error type constant. Defined in app/Config/logging.php.
  27. * @param string $scope The name of the log scope.
  28. * @return boolean Success of log write
  29. */
  30. public function log($msg, $type = LOG_ERR, $scope = null) {
  31. if (!is_string($msg)) {
  32. $msg = print_r($msg, true);
  33. }
  34. return Log::write($type, $msg, $scope);
  35. }
  36. }