move logging code from __init__ to log