@@ -663,6 +663,7 @@ func go_read_cookies(threadIndex C.uintptr_t) *C.char {
663663//export go_log
664664func go_log (threadIndex C.uintptr_t , message * C.char , level C.int ) {
665665 ctx := phpThreads [threadIndex ].context ()
666+ logger := phpThreads [threadIndex ].frankenPHPContext ().logger
666667
667668 m := C .GoString (message )
668669 le := syslogLevelInfo
@@ -673,47 +674,49 @@ func go_log(threadIndex C.uintptr_t, message *C.char, level C.int) {
673674
674675 switch le {
675676 case syslogLevelEmerg , syslogLevelAlert , syslogLevelCrit , syslogLevelErr :
676- if globalLogger .Enabled (ctx , slog .LevelError ) {
677- globalLogger .LogAttrs (ctx , slog .LevelError , m , slog .String ("syslog_level" , syslogLevel ( level ) .String ()))
677+ if logger .Enabled (ctx , slog .LevelError ) {
678+ logger .LogAttrs (ctx , slog .LevelError , m , slog .String ("syslog_level" , le .String ()))
678679 }
679680
680681 case syslogLevelWarn :
681- if globalLogger .Enabled (ctx , slog .LevelWarn ) {
682- globalLogger .LogAttrs (ctx , slog .LevelWarn , m , slog .String ("syslog_level" , syslogLevel ( level ) .String ()))
682+ if logger .Enabled (ctx , slog .LevelWarn ) {
683+ logger .LogAttrs (ctx , slog .LevelWarn , m , slog .String ("syslog_level" , le .String ()))
683684 }
685+
684686 case syslogLevelDebug :
685- if globalLogger .Enabled (ctx , slog .LevelDebug ) {
686- globalLogger .LogAttrs (ctx , slog .LevelDebug , m , slog .String ("syslog_level" , syslogLevel ( level ) .String ()))
687+ if logger .Enabled (ctx , slog .LevelDebug ) {
688+ logger .LogAttrs (ctx , slog .LevelDebug , m , slog .String ("syslog_level" , le .String ()))
687689 }
688690
689691 default :
690- if globalLogger .Enabled (ctx , slog .LevelInfo ) {
691- globalLogger .LogAttrs (ctx , slog .LevelInfo , m , slog .String ("syslog_level" , syslogLevel ( level ) .String ()))
692+ if logger .Enabled (ctx , slog .LevelInfo ) {
693+ logger .LogAttrs (ctx , slog .LevelInfo , m , slog .String ("syslog_level" , le .String ()))
692694 }
693695 }
694696}
695697
696698//export go_log_attrs
697699func go_log_attrs (threadIndex C.uintptr_t , message * C.zend_string , cLevel C.zend_long , cAttrs * C.zval ) * C.char {
698700 ctx := phpThreads [threadIndex ].context ()
701+ logger := phpThreads [threadIndex ].frankenPHPContext ().logger
699702
700703 level := slog .Level (cLevel )
701704
702- if ! globalLogger .Enabled (ctx , level ) {
705+ if ! logger .Enabled (ctx , level ) {
703706 return nil
704707 }
705708
706709 var attrs map [string ]any
707710
708711 if cAttrs != nil {
709712 var err error
710- if attrs , err = GoMap [any ](unsafe .Pointer (cAttrs )); err != nil {
713+ if attrs , err = GoMap [any ](unsafe .Pointer (* ( * * C . zend_array )( unsafe . Pointer ( & cAttrs . value [ 0 ])) )); err != nil {
711714 // PHP exception message.
712715 return C .CString ("Failed to log message: converting attrs: " + err .Error ())
713716 }
714717 }
715718
716- globalLogger .LogAttrs (ctx , level , GoString (unsafe .Pointer (message )), mapToAttr (attrs )... )
719+ logger .LogAttrs (ctx , level , GoString (unsafe .Pointer (message )), mapToAttr (attrs )... )
717720
718721 return nil
719722}
0 commit comments