Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
Logger.php
Go to the documentation of this file.
1<?php
2
3namespace Ubiquity\log;
4
14abstract class Logger {
19 private static $instance;
20 private static $active;
21
22 private static function createLogger(&$config) {
23 if (\is_callable ( $logger = $config ['logger'] )) {
24 $instance = $logger ();
25 } else {
26 $instance = $config ['logger'];
27 }
28 if ($instance instanceof Logger) {
29 self::$instance = $instance;
30 }
31 }
32
33 abstract public function _registerError();
34
35 public static function registerError() {
36 self::$instance->_registerError ();
37 }
38
39 public static function inContext($contexts, $context) {
40 if ($contexts === null) {
41 return true;
42 }
43 return \array_search ( $context, $contexts ) !== false;
44 }
45
46 public static function init(&$config,$application=false) {
47 if (($application || $config ['debug'] === true) && (self::$active = isset ( $config ['logger'] ))) {
48 self::createLogger ( $config );
49 }
50 }
51
52 public static function log($level, $context, $message, $part = null, $extra = null) {
53 if (self::$active){
54 self::$instance->_log ( $level, $context, $message, $part, $extra );
55 }
56 }
57
58 public static function info($context, $message, $part = null, $extra = null) {
59 if (self::$active){
60 self::$instance->_info ( $context, $message, $part, $extra );
61 }
62 }
63
64 public static function warn($context, $message, $part = null, $extra = null) {
65 if (self::$active){
66 self::$instance->_warn ( $context, $message, $part, $extra );
67 }
68 }
69
70 public static function error($context, $message, $part = null, $extra = null) {
71 if (self::$active){
72 self::$instance->_error ( $context, $message, $part, $extra );
73 }
74 }
75
76 public static function critical($context, $message, $part = null, $extra = null) {
77 if (self::$active){
78 self::$instance->_critical ( $context, $message, $part, $extra );
79 }
80 }
81
82 public static function alert($context, $message, $part = null, $extra = null) {
83 if (self::$active){
84 self::$instance->_alert ( $context, $message, $part, $extra );
85 }
86 }
87
88 public static function appLog($level, $context, $message, $part = null, $extra = null) {
89 self::$instance->_log ( $level, $context, $message, $part, $extra );
90 }
91
92 public static function appInfo($context, $message, $part = null, $extra = null) {
93 self::$instance->_info ( $context, $message, $part, $extra );
94 }
95
96 public static function appWarn($context, $message, $part = null, $extra = null) {
97 self::$instance->_warn ( $context, $message, $part, $extra );
98 }
99
100 public static function appError($context, $message, $part = null, $extra = null) {
101 self::$instance->_error ( $context, $message, $part, $extra );
102 }
103
104 public static function appCritical($context, $message, $part = null, $extra = null) {
105 self::$instance->_critical ( $context, $message, $part, $extra );
106 }
107
108 public static function appAlert($context, $message, $part = null, $extra = null) {
109 self::$instance->_alert ( $context, $message, $part, $extra );
110 }
111
112 public static function asObjects($reverse = true, $maxlines = 10, $contexts = null) {
113 if (isset ( self::$instance ) && self::$active){
114 return self::$instance->_asObjects ( $reverse, $maxlines, $contexts );
115 }
116 return [ ];
117 }
118
119 public static function clearAll() {
120 if (self::$active) {
121 self::$instance->_clearAll ();
122 }
123 }
124
125 public static function close() {
126 if (self::$active) {
127 self::$instance->_close ();
128 }
129 }
130
131 abstract public function _log($level, $context, $message, $part, $extra);
132
133 abstract public function _info($context, $message, $part, $extra);
134
135 abstract public function _warn($context, $message, $part, $extra);
136
137 abstract public function _error($context, $message, $part, $extra);
138
139 abstract public function _critical($context, $message, $part, $extra);
140
141 abstract public function _alert($context, $message, $part, $extra);
142
143 abstract public function _asObjects($reverse = true, $maxlines = 10, $contexts = null);
144
145 abstract public function _clearAll();
146
147 abstract public function _close();
148
149 public static function isActive() {
150 return self::$active;
151 }
152}
Abstract class for logging Ubiquity\log$Logger This class is part of Ubiquity.
Definition Logger.php:14
static appInfo($context, $message, $part=null, $extra=null)
Definition Logger.php:92
static registerError()
Definition Logger.php:35
_warn($context, $message, $part, $extra)
_alert($context, $message, $part, $extra)
static warn($context, $message, $part=null, $extra=null)
Definition Logger.php:64
_error($context, $message, $part, $extra)
static inContext($contexts, $context)
Definition Logger.php:39
static appLog($level, $context, $message, $part=null, $extra=null)
Definition Logger.php:88
static appCritical($context, $message, $part=null, $extra=null)
Definition Logger.php:104
_info($context, $message, $part, $extra)
_log($level, $context, $message, $part, $extra)
_critical($context, $message, $part, $extra)
static critical($context, $message, $part=null, $extra=null)
Definition Logger.php:76
static init(&$config, $application=false)
Definition Logger.php:46
static createLogger(&$config)
Definition Logger.php:22
static alert($context, $message, $part=null, $extra=null)
Definition Logger.php:82
static clearAll()
Definition Logger.php:119
_asObjects($reverse=true, $maxlines=10, $contexts=null)
static appWarn($context, $message, $part=null, $extra=null)
Definition Logger.php:96
static asObjects($reverse=true, $maxlines=10, $contexts=null)
Definition Logger.php:112
static appError($context, $message, $part=null, $extra=null)
Definition Logger.php:100
static isActive()
Definition Logger.php:149
static appAlert($context, $message, $part=null, $extra=null)
Definition Logger.php:108
static log($level, $context, $message, $part=null, $extra=null)
Definition Logger.php:52
static error($context, $message, $part=null, $extra=null)
Definition Logger.php:70
static info($context, $message, $part=null, $extra=null)
Definition Logger.php:58