In verse four, the author says that God kept his eyes from closing. God has reasons for what he does.
But in the meantime, things were pretty rough. Lying awake with memories of things that went wrong, mistakes made, in distress and nothing was able to comfort him. The author was in such despair that he questioned if God had forgotten his promise. If things would always be this bad and if God's everlasting love had vanished.
In the darkness of night it's hard to remember God's promises that things will get better. It's way too easy to get overwhelmed by the lies that fill your mind.
But the author goes hold on. We're not doing this anymore. Take captive every thought! (2 Corinthians 10:5) He says that he will remember everything that God has done. He replaces the lies with all of the miracles and things that God has done in his life. (Psalm 77:10-20)
It's a great example of how to try to fight the lies. Remember how God has caused you to grow, how he works in your life and the lives of people that are close to you. Thank him for what he's done and try to focus on those good things rather than the bad that you face. :)
You won't need to fear the night:) (Psalm 91:5)