Detecting bulk and edge exceptional points in non-Hermitian systems through generalized Petermann factors