main: log_type and log_prefix flags, minor refactor