Fix `TaggedLogging` when `progname` is displayed and optimize it using t...

...he severity

`ActiveSupport::TaggedLogging` does not correctly display a message when a formatter is used that outputs `progname`.
Ex: progname = 'PROG'
`[Funky time] [BCX] Funky time` was displayed instead of `[PROG] [BCX] Funky time`

When a block is given, it will only be evaluated if the severity is greater than or equal to logger's level.

Resubmitting pull request #10829. It should be applicable only for rails <= 3.2.13.