A Flexible Empirical Bayes Approach to Generalized Linear Models, with Applications to Sparse Logistic Regression