For numpy arrays you can calculate the log and then apply a simple mask.
>>> a=np.exp(np.arange(-3,3,dtype=np.float))
>>> b=np.log(a)
>>> b
array([-3., -2., -1., 0., 1., 2.])
>>> b[b<=0]=-np.inf
>>> b
array([-inf, -inf, -inf, -inf, 1., 2.])
To save a bit of time and to have the option of calling in place or creating a new array:
def inf_log(arr,copy=False):
mask= (arr<=1)
notmask= ~mask
if copy==True:
out=arr.copy()
out[notmask]=np.log(out[notmask])
out[mask]=-np.inf
return out
else:
arr[notmask]=np.log(arr[notmask])
arr[mask]=-np.inf