Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
LogMessage.php
Go to the documentation of this file.
1<?php
2
3namespace Ubiquity\log;
4
5class LogMessage {
6
7 private $message;
8 private $context;
9 private $part;
10 private $level;
11 private $extra;
12 private $datetime;
13 private $count=1;
14
15 public function __construct($message="",$context="",$part="",$level=0,$datetime=null,$extra=null){
16 $this->message=$message;
17 $this->context=$context;
18 $this->part=$part;
19 $this->level=$level;
20 $this->datetime=$datetime;
21 $this->extra=$extra;
22 }
26 public function getMessage() {
27 return $this->message;
28 }
29
33 public function getContext() {
34 return $this->context;
35 }
36
40 public function getPart() {
41 return $this->part;
42 }
43
47 public function getLevel() {
48 return $this->level;
49 }
50
54 public function getExtra() {
55 return $this->extra;
56 }
57
61 public function getDatetime() {
62 return $this->datetime;
63 }
64
68 public function setMessage($message) {
69 $this->message = $message;
70 }
71
75 public function setContext($context) {
76 $this->context = $context;
77 }
78
82 public function setPart($part) {
83 $this->part = $part;
84 }
85
89 public function setLevel($level) {
90 $this->level = $level;
91 }
92
96 public function setExtra($extra) {
97 $this->extra = $extra;
98 }
99
103 public function setDatetime($datetime) {
104 $this->datetime = $datetime;
105 }
106
107 public function incCount(){
108 $this->count++;
109 }
113 public function getCount() {
114 return $this->count;
115 }
116
117 public function equals(LogMessage $message){
118 return $this->message===$message->getMessage() && $this->context===$message->getContext() && $this->part===$message->getPart();
119 }
120
121 public static function addMessage(&$messages,LogMessage $newMessage){
122 if(!empty($messages)){
123 $lastM=end($messages);
124 if($newMessage->equals($lastM)){
125 return $lastM->incCount();
126 }
127 }
128 $messages[]=$newMessage;
129 }
130
131}
132
static addMessage(&$messages, LogMessage $newMessage)
__construct($message="", $context="", $part="", $level=0, $datetime=null, $extra=null)
equals(LogMessage $message)