added optional logging methods plus debugstate enum