Well, first of I just have to say that tinkering with mains voltage can very well be lethal if you are not extremely careful, and probably isn't legal either. At least it isn't here in Norway, or any other place I know of.
However, for the purpouse of knowing, I guess I can tell you one way of doing what you want. A voltage divider.
You connect 2 resistors in series between the two main phases of your mains wireing. These two have to be very large to keep the current passing through them very low thus keeping the effect (watts) as low as possible. Also, they must be rated above the voltages you are going to be working with (wether it is 115V or 230V).
The ratio between these two resistors is what determines your range of output voltage. If one resistor is 50 times larger than the other, the voltage measuret between them will be 1/50 of the mains voltage. If you used (this is an example, do NOT go out and kill yourself by taking my advice or using my numbers!
) one resistor of 60MOhms (60 million Ohms) and one of 10MOhms you would measure roughly 3,83 volts if your mains voltage is 230V.Ok, sorry, I just read up on the wikipedia page below and I was a bit off on the ratio of the resistors in the voltage divider. Read about it or experiment on low voltages yourself until you understand it before you try it on mains voltage!http://en.wikipedia.org/wiki/Voltage_divider
You'd need to rectify (turn AC to DC) the voltage you get out before measuring it too, but this is quite simple and uses only 4 diodes. http://en.wikipedia.org/wiki/Diode_bridge
With that setup (again, do NOT trust my values for resistors, etc.! I do NOT take responsibility for anything you might screw up and damage as a result of reading this!) connected to an analog input, you can measure both frequency and voltage with a little bit of nifty programming. The rectifier I linked to does not smooth the signal, just turns it into DC, so it would be jumping up and down between max voltage and 0V at the same frequency as your mains voltage.
Hope it helps, and again, I am not responsible for you killing/hurting yourself and/or others, or damaging/destroing equipment (or burning down your house/neighbourhood). With that said, Happy Hacking! =P