LogTrait.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  10. * @link https://cakephp.org CakePHP(tm) Project
  11. * @since 3.0.0
  12. * @license https://opensource.org/licenses/mit-license.php MIT License
  13. */
  14. namespace Cake\Log;
  15. use Psr\Log\LogLevel;
  16. /**
  17. * A trait providing an object short-cut method
  18. * to logging.
  19. */
  20. trait LogTrait
  21. {
  22. /**
  23. * Convenience method to write a message to Log. See Log::write()
  24. * for more information on writing to logs.
  25. *
  26. * @param mixed $msg Log message.
  27. * @param int|string $level Error level.
  28. * @param string|array $context Additional log data relevant to this message.
  29. * @return bool Success of log write.
  30. */
  31. public function log($msg, $level = LogLevel::ERROR, $context = [])
  32. {
  33. return Log::write($level, $msg, $context);
  34. }
  35. }