Skip to content

Commit d36a064

Browse files
burgesQdunglas
authored andcommitted
misc(logging): clean up
1 parent 9c22465 commit d36a064

2 files changed

Lines changed: 1 addition & 40 deletions

File tree

frankenphp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ PHP_FUNCTION(frankenphp_log) {
566566
ret = go_log_attrs(thread_index, message, message_len, (int)level, context);
567567
if (ret != NULL) {
568568
zend_throw_exception(spl_ce_RuntimeException, ret, 0);
569-
// free(ret); // NOTE: is the string copied by zend_throw ??
569+
free(ret);
570570
RETURN_THROWS();
571571
}
572572
}

frankenphp.go

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -693,45 +693,6 @@ func go_log(threadIndex C.uintptr_t, message *C.char, level C.int) {
693693
}
694694
}
695695

696-
// go_log_attrs is a cgo-exported bridge between PHP and the Go slog logger.
697-
//
698-
// It is called from C/PHP and must not panic. All errors are reported by
699-
// returning a C-allocated error string; on success it returns NULL.
700-
//
701-
// Parameters:
702-
//
703-
// threadIndex:
704-
// - Index into the phpThreads table, used to retrieve the Go context for
705-
// the current PHP request/thread.
706-
//
707-
// message:
708-
// - Pointer to a C string containing the log message bytes. The memory
709-
// is owned by the caller and must NOT be freed by Go.
710-
//
711-
// len:
712-
// - Length of the message, in bytes, as seen from C (not including the
713-
// terminating NUL). This is passed to C.GoStringN to build the Go string.
714-
//
715-
// level:
716-
// - Numeric log level compatible with slog.Level values. It is cast to
717-
// slog.Level inside this function.
718-
//
719-
// cattrs:
720-
// - Pointer to a PHP zval representing an associative array of attributes,
721-
// or NULL. When non-NULL, it is converted to map[string]any via GoMap[any]
722-
// and then mapped to slog.Attr values (using slog.Any under the hood).
723-
//
724-
// Return value:
725-
//
726-
// On success:
727-
// - Returns NULL and the message is logged (if the logger is enabled at
728-
// the given level).
729-
//
730-
// On error:
731-
// - Returns a non-NULL *C.char pointing to a NUL-terminated error message
732-
// allocated with C.CString. The caller is responsible for releasing
733-
// this memory.
734-
//
735696
//export go_log_attrs
736697
func go_log_attrs(threadIndex C.uintptr_t, message *C.char, len C.int, level C.int, cattrs *C.zval) *C.char {
737698
var attrs map[string]any

0 commit comments

Comments
 (0)