logger: more testable and readable

adds logger.levels
populate constants from levels
extracted an anonymous function expression into log_if_level()
adds add_log_methods(), populates an object with logging methods

adds tests for log_if_level() and add_log_methods()