Psalm 4 moves through a few different themes pretty quickly. The Psalmist (probably David) begins by calling on God and asking him to deliver the speaker from trouble, as he has already done in times past.
Verse 2 changes tacks and addresses a totally different audience: sinful people. The speaker is pretty fed up with people in general and their vanity. The speaker contrasts this bad behavior with that of the godly people God has set apart as his own special people. The speaker counts himself among these special people and indicates that this is why the Lord will answer his prayer.
Verse 4 seems to be addressing no one in particular, just offering a piece of advice for everyone and saying that people should be so much in awe of God that they avoid sin. The verse also encourages quiet meditation and personal reflection. I'm not entirely sure what "sacrifices of righteousness" are in the next verse, but they seem to be more of a spiritual thing than a literal animal sacrifice such as the ones Jews commonly offered at that time.
Verse 6 deals with people who are discouraged and who think God will not aid them. The speaker asks God to look at his people and remember them.
Verses 7 and 8 address God directly again, telling God that he has made the speaker's heart happy, in a way that exceeds even the merriment that comes during the harvest festivals. The speaker concludes that he is entirely safe and can rest securely, knowing that God is his protection.
1Hear me when I call, O God of my righteousness: thou hast enlarged me when I was in distress; have mercy upon me, and hear my prayer.
2 O ye sons of men, how long will ye turn my glory into shame? how long will ye love vanity, and seek after leasing? Selah.
3 But know that the Lord hath set apart him that is godly for himself: the Lord will hear when I call unto him.
4 Stand in awe, and sin not: commune with your own heart upon your bed, and be still. Selah.
5 Offer the sacrifices of righteousness, and put your trust in the Lord.
6 There be many that say, Who will shew us any good? Lord, lift thou up the light of thy countenance upon us.
7 Thou hast put gladness in my heart, more than in the time that their corn and their wine increased.
8 I will both lay me down in peace, and sleep: for thou, Lord, only makest me dwell in safety.