Created
May 4, 2017 13:27
-
-
Save nkundu/da648d34959f0390d9d2cf6b1bd54df8 to your computer and use it in GitHub Desktop.
Use C# Caller Member Name as a Logger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
CREATE PROCEDURE [dbo].[ADD_ACTIVITY_LOG] | |
-- Add the parameters for the stored procedure here | |
@activityDate datetime, | |
@activityDesc nvarchar(100), | |
@activityDetail nvarchar(MAX) | |
AS | |
BEGIN | |
-- SET NOCOUNT ON added to prevent extra result sets from | |
-- interfering with SELECT statements. | |
SET NOCOUNT ON; | |
-- Insert statements for procedure here | |
INSERT INTO [dbo].[ACTIVITY_LOG] | |
([ACTIVITY_DATE] | |
,[ACTIVITY_DESC] | |
,[ACTIVITY_DETAIL]) | |
VALUES | |
(@activityDate | |
,@activityDesc | |
,@activityDetail) | |
END | |
*/ | |
public static void AddActivityLog(string detail, | |
[System.Runtime.CompilerServices.CallerMemberName] string memberName = "") | |
{ | |
using (var conn = Util.GetConnection()) | |
{ | |
conn.Query("ADD_ACTIVITY_LOG", new { activityDate = DateTime.Now, activityDesc = memberName, activityDetail = detail }, commandType: CommandType.StoredProcedure); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment