Why won’t console.log run in if statement

I’m using supabase to authenticate users. I’m trying to return a message to the console if it fails however I can’t get the console.log to work. I know the function is working because I can get it to redirect if there’s an error, but I want to return the message as well

'use server'

import { revalidatePath } from 'next/cache'
import { redirect } from 'next/navigation'

import { createClient } from '../../utils/supabase/server'

export async function login() {
  const supabase = await createClient()

  const { data, error } = await supabase.auth.signInAnonymously()

  if (error) {
    console.log(error)
    // redirect('/anonlogin')
  } else {
    revalidatePath('/', 'layout')
    redirect('/')
  }
}