export go_log_attrs
(threadIndex C.uintptr_t, message *C.zend_string, cLevel C.zend_long, cAttrs *C.zval)
| 718 | |
| 719 | //export go_log_attrs |
| 720 | func go_log_attrs(threadIndex C.uintptr_t, message *C.zend_string, cLevel C.zend_long, cAttrs *C.zval) *C.char { |
| 721 | logger, ctx := getLogger(threadIndex) |
| 722 | |
| 723 | level := slog.Level(cLevel) |
| 724 | |
| 725 | if !logger.Enabled(ctx, level) { |
| 726 | return nil |
| 727 | } |
| 728 | |
| 729 | var attrs map[string]any |
| 730 | |
| 731 | if cAttrs != nil { |
| 732 | var err error |
| 733 | if attrs, err = GoMap[any](unsafe.Pointer(*(**C.zend_array)(unsafe.Pointer(&cAttrs.value[0])))); err != nil { |
| 734 | // PHP exception message. |
| 735 | return C.CString("Failed to log message: converting attrs: " + err.Error()) |
| 736 | } |
| 737 | } |
| 738 | |
| 739 | logger.LogAttrs(ctx, level, GoString(unsafe.Pointer(message)), mapToAttr(attrs)...) |
| 740 | |
| 741 | return nil |
| 742 | } |
| 743 | |
| 744 | func mapToAttr(input map[string]any) []slog.Attr { |
| 745 | out := make([]slog.Attr, 0, len(input)) |