CREATEPROCEDURE[dbo].[prApp_Log_Add]-- Add the parameters for the stored procedure here
@logtypenvarchar(50)='',@messagenvarchar(MAX)=''AS-- Insert statements for procedure here
INSERTLog(logtype,message)VALUES(@logtype,@message);GO
try{intresult=DAL.DBLog.addLogEntry(message,logType.ToString());if(result<1)Console.WriteLine(DateTime.Now.ToString()+": Utils.Log("+message+", "+logType.ToString()+") database entry result is "+result+".");}catch(System.IO.IOException){Console.WriteLine(DateTime.Now.ToString()+": Threw an IOException at Utils.Log("+message+", "+logType.ToString()+").");Console.Write("> ");}catch(Exception){Console.WriteLine(DateTime.Now.ToString()+": Threw an Exception at Utils.Log("+message+", "+logType.ToString()+").");Console.Write("> ");}
(Will I ever get an IOException here? Doubtful. Admitted cut-and-paste from other pieces of logging code.)
And presto:
Now this we can use.
So let’s add some other saved procedures for easy access:
That should make it easy to remember a point in time, run a test, and then grab everything that happened during it. Note my avoidance of using the timestamps, which can sometimes be a pain to deal with. (Should I have made the ID something larger than int? Are the logs that busy? Time will certainly tell.)
In order to be prepared, I’ve decided to kind of shelve things for the moment, and spend the time getting a little more familiar with a toolset in general.