connection management

Hello everyone. I'm here for the first time, so if I'm not on the right track, please feel free to guide me.
I am looking for a function that would mute all incoming calls (and ideally, even when operating the program, it would not show them on the screen, but create a file / database with these connections), and at the same time retrieve the number that was trying to get through. I am asking for tips and help in any way.