1: <?php
2: /**
3: * Fluent-Logger-PHP
4: *
5: * Copyright (C) 2011 - 2012 Fluent-Logger-PHP Contributors
6: *
7: * Licensed under the Apache License, Version 2.0 (the "License");
8: * you may not use this file except in compliance with the License.
9: * You may obtain a copy of the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS,
15: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: * See the License for the specific language governing permissions and
17: * limitations under the License.
18: */
19: namespace Fluent\Logger;
20:
21: class Entity
22: {
23: public $time;
24: public $tag;
25: public $data = array();
26:
27: /**
28: * create a entity for sending to fluentd server
29: *
30: * @param $tag
31: * @param $data
32: * @param int $time unixtime
33: */
34: public function __construct($tag, $data, $time = null)
35: {
36: if (is_long($time)) {
37: $this->time = $time;
38: } else {
39: if (!is_null($time)) {
40: error_log("Entity::__construct(): unexpected time format `{$time}` specified.");
41: }
42:
43: $this->time = time();
44: }
45:
46: $this->tag = $tag;
47: $this->data = $data;
48: }
49:
50: /**
51: * get current tag
52: *
53: * @return string tag
54: */
55: public function getTag()
56: {
57: return $this->tag;
58: }
59:
60: /**
61: * get current data
62: *
63: * @return array
64: */
65: public function getData()
66: {
67: return $this->data;
68: }
69:
70: /**
71: * get current unixtime
72: *
73: * @return int
74: */
75: public function getTime()
76: {
77: return $this->time;
78: }
79: }