log.php 892 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. /**
  9. * logging utilities
  10. *
  11. * Log is saved by default at data/owncloud.log using OC_Log_Owncloud.
  12. * Selecting other backend is done with a config option 'log_type'.
  13. */
  14. class OC_Log {
  15. const DEBUG=0;
  16. const INFO=1;
  17. const WARN=2;
  18. const ERROR=3;
  19. const FATAL=4;
  20. static protected $class = null;
  21. /**
  22. * write a message in the log
  23. * @param string $app
  24. * @param string $message
  25. * @param int level
  26. */
  27. public static function write($app, $message, $level) {
  28. if (!self::$class) {
  29. self::$class = 'OC_Log_'.ucfirst(OC_Config::getValue('log_type', 'owncloud'));
  30. call_user_func(array(self::$class, 'init'));
  31. }
  32. $log_class=self::$class;
  33. $log_class::write($app, $message, $level);
  34. }
  35. }