-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebug.php
More file actions
54 lines (45 loc) · 1.76 KB
/
Debug.php
File metadata and controls
54 lines (45 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
//
// +-----------------------------------------------------------+
// | Debug.php |
// +-----------------------------------------------------------+
// | Put your description here |
// +-----------------------------------------------------------+
// | Copyright (©) 2022 |
// +-----------------------------------------------------------+
// | Authors: Mehernosh Mohta <emnosh.pro@gmail.com.au> |
// +-----------------------------------------------------------+
//
namespace EM\Log;
class Debug
{
public static function getArgument($arg)
{
switch (strtolower(gettype($arg))) {
case 'string':
return ('"' . str_replace(array("\n"), array(''), $arg) . '"');
case 'boolean':
return (bool)$arg;
case 'object':
return 'Object(' . get_class($arg) . ')';
case 'array':
return 'Array(' . count($arg) . ')';
case 'resource':
return 'Resource('.get_resource_type($arg).')';
default:
return var_export($arg, true);
}
}
public static function log($arg, String $message = null)
{
error_log(__METHOD__.'@'.__LINE__);
ob_start();
var_dump($arg);
$contents = ob_get_contents();
ob_end_clean();
if (!is_null($message)) {
error_log($message);
}
error_log(str_replace(["\r", "\n"], [''], $contents));
}
}