I write a tool,the main process include CRUD,I want to write each step to log so we can monitor the process,more I want report the process to the GUI listbox(backgroundworker worker.reportprocess)
So, the code structure is like this:
deleteFile(xxxx);
LogHelper.log("deleteFile"+xxxx);
worker.ReportProgress(xxx);
moveFile(xxx);
LogHelper.log("moveFile"+xxx);
worker.ReportProgress(xxx);
unzipFile(xxx);
LogHelper.log("unzipFile"+xxx);
worker.ReportProgress(xxx);
...
The business code is mixed with the log code, I think it reduces the readability and maintainability of code
So, What is the best way to write log code in software?
Aucun commentaire:
Enregistrer un commentaire