Often you can't directly work out the cost of a thing itself.
You can instead work out the value of the best alternative forgone.
For example, writing "Yet Another Logging Framework" might seem to cost you 1 week. But if it stopped you from writing "The Million Dollar Feature" — then it has an opportunity cost of 1 million dollars.