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: /* @var int unxitime */
24: public $time;
25:
26: /* @var string Fluentd tag */
27: public $tag;
28:
29: /* @var array structured log data */
30: public $data = array();
31:
32: /**
33: * create a entity for sending to fluentd server
34: *
35: * @param $tag
36: * @param $data
37: * @param int $time unixtime
38: */
39: public function __construct($tag, $data, $time = null)
40: {
41: if (is_long($time)) {
42: $this->time = $time;
43: } else {
44: if (!is_null($time)) {
45: error_log("Entity::__construct(): unexpected time format `{$time}` specified.");
46: }
47:
48: $this->time = time();
49: }
50:
51: $this->tag = $tag;
52: $this->data = $data;
53: }
54:
55: /**
56: * get current tag
57: *
58: * @return string tag
59: */
60: public function getTag()
61: {
62: return $this->tag;
63: }
64:
65: /**
66: * get current data
67: *
68: * @return array
69: */
70: public function getData()
71: {
72: return $this->data;
73: }
74:
75: /**
76: * get current unixtime
77: *
78: * @return int
79: */
80: public function getTime()
81: {
82: return $this->time;
83: }
84: }