You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/BuffLog/BuffLog.php
+35-6Lines changed: 35 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -45,8 +45,12 @@ protected static function configureInstance()
45
45
} else {
46
46
// local envs don't need tracing
47
47
if (getenv("ENVIRONMENT") !== "local") {
48
-
error_log("Tip #1: Can't find \DDTrace\GlobalTracer class. Did you install the Datadog APM tracer extension? It will allow you to have logs enriched with traces making troubleshooting easier.");
49
-
error_log("Tip #2: If you run a cli mode service (such as a worker), did you set the DD_TRACE_CLI_ENABLED env variable?");
48
+
echojson_encode([
49
+
"message" => "Can't find \DDTrace\GlobalTracer class. Did you install the Datadog APM tracer extension? It will allow you to have logs enriched with traces making troubleshooting easier. If you run a cli mode service (such as a worker), did you set the DD_TRACE_CLI_ENABLED env variable?",
50
+
"level" => 300,
51
+
"level_name" => "WARNING",
52
+
"context" => ["bufflog_error" => "no_tracer"]
53
+
]);
50
54
}
51
55
}
52
56
@@ -110,15 +114,40 @@ public static function __callStatic($methodName, $args)
110
114
if (in_array($methodName, array_merge(self::$logOutputMethods, self::$extraAllowedMethods))) {
111
115
112
116
if (in_array($methodName, self::$logOutputMethods)) {
113
-
// Where the magic happen. We "proxy" functions name with arguments to the Monolog instance
error_log("BuffLog::$methodName() is not supported yet. Add it to the BuffLog whitelist to allow it");
124
+
self::getLogger()->warning("BuffLog::$methodName() is not supported yet. Add it to the BuffLog whitelist to allow it", ["bufflog_error" => "method_not_supported"]);
118
125
}
119
126
} else {
120
-
error_log("BuffLog::$methodName() method does not exist");
127
+
self::getLogger()->warning("BuffLog::$methodName() method does not exist", ["bufflog_error" => "method_not_exist"]);
self::getLogger()->warning("BuffLog: Malformed logs: Too many parameters", ["bufflog_error" => "incorrect_parameters", "args" => $args]);
137
+
returnfalse;
121
138
}
139
+
140
+
if (isset($args[0]) && !is_string($args[0])) {
141
+
self::getLogger()->warning("BuffLog: Malformed logs: First parameter must be a string", ["args" => $args, "bufflog_error" => "incorrect_parameters"]);
142
+
returnfalse;
143
+
}
144
+
145
+
if (isset($args[1]) && !is_array($args[1])) {
146
+
self::getLogger()->warning("BuffLog: Malformed logs: Second parameter must be an array", ["args" => $args, "bufflog_error" => "incorrect_parameters"]);
0 commit comments