fix a bug and improve the security.
Merge pull request #2 from yohe/logging_mode

fix a bug and improve the security.