1 | <?php |
||
9 | class ImportLogger { |
||
10 | |||
11 | protected $levels_delimiter = '/'; |
||
12 | |||
13 | protected $data = [ |
||
14 | 'info' => [], |
||
15 | 'error' => [], |
||
16 | 'success' => [], |
||
17 | ]; |
||
18 | |||
19 | /** |
||
20 | * @var ImportCoordinates |
||
21 | */ |
||
22 | protected $import_coordinates; |
||
23 | |||
24 | public function __construct( ImportCoordinates $import_coordinates ) { |
||
27 | |||
28 | /** |
||
29 | * Merges the specified log data into this log. |
||
30 | * |
||
31 | * @param ImportLogger|null $logger |
||
32 | */ |
||
33 | public function merge( ImportLogger $logger = null ) { |
||
40 | |||
41 | /** |
||
42 | * @return array |
||
43 | */ |
||
44 | public function get_data() { |
||
47 | |||
48 | /** |
||
49 | * Saves the log or prints it some place. |
||
50 | */ |
||
51 | public function save() { |
||
79 | |||
80 | /** |
||
81 | * Logs an error. |
||
82 | * |
||
83 | * @param string $where A location string using `/` as level format. |
||
84 | * @param mixed $what What should be stored in the log. |
||
85 | */ |
||
86 | public function log_error( $where, $what ) { |
||
89 | |||
90 | /** |
||
91 | * Logs something. |
||
92 | * |
||
93 | * @param string $where A location string using `/` as level format. |
||
94 | * @param mixed $what What should be stored in the log. |
||
95 | * @param string $root Where to log the information. |
||
96 | */ |
||
97 | protected function log( $where, $what, $root = 'info' ) { |
||
107 | |||
108 | protected function build_nested_array( $path, $what = '' ) { |
||
121 | |||
122 | /** |
||
123 | * @param $where |
||
124 | * |
||
125 | * @return array |
||
126 | */ |
||
127 | protected function build_path( $where ) { |
||
132 | |||
133 | /** |
||
134 | * Returns the string that will be used to split paths into levels. |
||
135 | * |
||
136 | * @return string |
||
137 | */ |
||
138 | public function get_levels_delimiter() { |
||
141 | |||
142 | /** |
||
143 | * Sets the string that will be used to split paths into levels. |
||
144 | * |
||
145 | * @param string $levels_delimiter |
||
146 | */ |
||
147 | public function set_levels_delimiter( $levels_delimiter ) { |
||
150 | |||
151 | /** |
||
152 | * Logs a success. |
||
153 | * |
||
154 | * @param string $where A location string using `/` as level format. |
||
155 | * @param mixed $what What should be stored in the log. |
||
156 | */ |
||
157 | public function log_success( $where, $what ) { |
||
160 | |||
161 | /** |
||
162 | * Logs some generic information. |
||
163 | * |
||
164 | * @param string $message |
||
165 | */ |
||
166 | public function log_information( $key, $message ) { |
||
169 | |||
170 | public function get_error( $where ) { |
||
173 | |||
174 | /** |
||
175 | * @param $where |
||
176 | * |
||
177 | * @return mixed |
||
178 | */ |
||
179 | protected function get_nested_value( $where ) { |
||
190 | |||
191 | public function get_success( $where ) { |
||
194 | |||
195 | public function get_information( $key ) { |
||
198 | } |