Skip to content

Commit ee7d418

Browse files
committed
misc(logging): clean up
1 parent ee4dbbb commit ee7d418

File tree

2 files changed

+1
-40
lines changed

2 files changed

+1
-40
lines changed

frankenphp.c

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

frankenphp.go

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

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

0 commit comments

Comments
 (0)