I think that, if you connect the Pi to a powerbank, and keep the charger connected to the powerbank- it might work. I have never tried such a thing.
new_user wroteI would go with the guys who suggested the raspberry pi. You can easily get a 3 volt DC power adapter. Connect it to the power line from one end. Strip the head from the other end and connect it to an input pin and write a script to log the time the input pin is supplied with power and the time it is not.
I read that the Pi does not have an analog input, that you have to connect it to an Arduino or AD converter to measure voltage - which you could also use for doing other cool things.
Also if it's an external voltage then you need to connect two pins (+ and -) because it's a different ground loop.
Maybe instead, you can get a relay that you can control with the 3 (or more) volt signal.
Please correct me if I'm wrong!