1
0

log.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * @author Bart Visscher <bartv@thisnet.nl>
  4. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  5. * @author Morris Jobke <hey@morrisjobke.de>
  6. * @author Thomas Müller <thomas.mueller@tmit.eu>
  7. *
  8. * @copyright Copyright (c) 2015, ownCloud, Inc.
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. /**
  25. * logging utilities
  26. *
  27. * Log is saved by default at data/owncloud.log using OC_Log_Owncloud.
  28. * Selecting other backend is done with a config option 'log_type'.
  29. */
  30. OC_Log::$object = new \OC\Log();
  31. /**
  32. * @deprecated use \OC::$server->getLogger() to get an \OCP\ILogger instance
  33. */
  34. class OC_Log {
  35. public static $object;
  36. const DEBUG=0;
  37. const INFO=1;
  38. const WARN=2;
  39. const ERROR=3;
  40. const FATAL=4;
  41. static private $level_funcs = array(
  42. self::DEBUG => 'debug',
  43. self::INFO => 'info',
  44. self::WARN => 'warning',
  45. self::ERROR => 'error',
  46. self::FATAL => 'emergency',
  47. );
  48. static public $enabled = true;
  49. static protected $class = null;
  50. /**
  51. * write a message in the log
  52. * @param string $app
  53. * @param string $message
  54. * @param int $level
  55. */
  56. public static function write($app, $message, $level) {
  57. if (self::$enabled) {
  58. $context = array('app' => $app);
  59. $func = array(self::$object, self::$level_funcs[$level]);
  60. call_user_func($func, $message, $context);
  61. }
  62. }
  63. }