PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.9.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.9.1
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
bit-form / includes / Core / Util / Log.php

Log.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.9.1, at includes/Core/Util/Log.php

66 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Core\Util;
4
5 final class Log
6 {
7 public static function get_backtrace_info()
8 {
9 $trace = debug_backtrace();
10
11 $file = $trace[1]['file'];
12 $class = $trace[2]['class'];
13 $func = $trace[2]['function'];
14 $type = $trace[2]['type'];
15 $line = $trace[1]['line'];
16
17 $output = sprintf(
18 '%s%s%s() at %s on line %s',
19 $class,
20 $type,
21 $func,
22 $file,
23 $line
24 );
25
26 return $output;
27 }
28
29 public static function debug_log($log)
30 {
31 $trace_info = self::get_backtrace_info();
32 if (WP_DEBUG === true) {
33 if (is_array($log) || is_object($log)) {
34 if (is_array($log)) {
35 $log['trace'] = $trace_info;
36 } else {
37 $log->trace = $trace_info;
38 }
39 $log_msg = print_r($log, true);
40 } else {
41 $log_msg = $log . ' in ' . $trace_info;
42 }
43
44 error_log($log_msg);
45 }
46 }
47
48 public static function print($log, $path = '', $fileName = 'print.log', $fileOpenMode = 'a')
49 {
50 $rootDir = BITFORMS_CONTENT_DIR;
51 $path = trim($path, '/');
52 $pathArr = explode('/', $path); // like "fieldname/user => [Fieldname, user]
53 foreach ($pathArr as $d) {
54 $rootDir .= $d . DIRECTORY_SEPARATOR;
55 if (!realpath($rootDir)) {
56 mkdir($rootDir);
57 }
58 }
59 $fullPath = $rootDir . $fileName;
60 $file = fopen($fullPath, $fileOpenMode);
61 fwrite($file, $log);
62 fclose($file);
63 return true;
64 }
65 }
66