id still love a way to get the error logs from the...
# sql
s
id still love a way to get the error logs from the database
b
I haven't looked at this in months, but it should still work for you: https://github.com/burggraf/SupabaseLogQuery
s
Heads up, this doesnt work
@User
b
What error are you getting?
There is corruption in a lot of logs so I'm not sure what will cause it to fail. But if I can get examples I can over those cases.
Doh! I deleted the code that creates the log table. Let me fix that!
All fixed. Can you try it now, @User ?
Thanks for catching that, BTW.
s
So It doesnt appear to be returning any row when it should be
Copy code
drop table if exists user_roles;
drop type if exists custom_user_roles;

CREATE TYPE custom_user_roles AS ENUM ('user','approver','admin');

create table user_roles (
  id uuid references auth.users not null unique,
  role custom_user_roles not null default 'user',

  primary key (id)
);

alter table user_roles enable row level security;

create or replace function add_default_user()
  returns trigger as
$$
begin
  insert into public.user_roles(id, role) VALUES (NEW.id, 'user');
  return NEW;
end;
$$
language 'plpgsql' SECURITY DEFINER;

drop trigger if exists default_user_role on auth.users;
create trigger default_user_role after insert on auth.users execute procedure add_default_user();
This is my user_roles table
and when I create a new user, it throws an error
But i get that when I run it
@User
b
This doesn't seem to be the right thread.
s
I am trying to run the error log
from the database
b
I've been working today on accessing the pg error logs
I've completely redone it
s
Copy code
CREATE EXTENSION IF NOT EXISTS file_fdw;
CREATE SERVER IF NOT EXISTS logserver FOREIGN DATA WRAPPER file_fdw;
CREATE FOREIGN TABLE IF NOT EXISTS postgres_log_text (log_entry text) 
   SERVER logserver OPTIONS (program 'tac pg_log/postgresql.csv', format 'text');

-- 
-- read the most recent 20 entries from the log file
--
SELECT log_entry from postgres_log_text LIMIT 20;
b
but your code here has nothing to do with the table
s
Im just show you the source of the error
b
Yeah that's the basic code for reading the log as text
s
incase creating a new user and a trigger failing wouldnt log the results
b
What happens when you do the
SELECT log_entry from postgres_log_text LIMIT 20;
I don't know if you'll see anything in the logs about creating users
s
the second image
this
But i am for sure getting errors
b
I'm saying I don't know what gets written to the postgres log
don't know if it logs errors like that, you'd have to ask steve or someone who know pg internals better
s
Ahh this whole error log stemed from a comment i made last week about creating a user and getting a database error i couldnt see
gotcha
I was linked to this thread
b
Yeah, this is the standard postgres log file, which you can take a look at
I completely redid most of this today (except the part you just pasted, that's the same)
but now I load the load file into a table which you can query
in a small % of cases it doesn't work though because the log file can be super corrupt sometimes
but for the most part this works and shows you what's in the log. ... whether the log is helpful or not, I'm not sure 🙂
s
I appreciate the work
I really do
I am a hobbyist, so I am learning as I go
So sometimes I am just jacked up and it has nothing to do with supabase
b
if you go to run the new version of SupabaseLogQuery you might want to uncomment the first 4 lines that delete any existing tables or functions related to logging
we're all just learning 🙂
I learned so much about pg today...doing this project...