Click here to Skip to main content
15,886,693 members
Articles / Desktop Programming / XAML

Diagnostic Explorer

Rate me:
Please Sign up or sign in to vote.
4.93/5 (41 votes)
29 Nov 2010LGPL315 min read 82.3K   1.5K   120  
A .NET library and website which allows developers to expose and view arbitrary diagnostic information about their .NET processes.
/****** Object:  Table [dbo].[Diagnostics]    Script Date: 02/21/2010 17:42:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Diagnostics](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Date] [datetime] NOT NULL,
	[Category] [varchar](50) NULL,
	[Severity] [int] NOT NULL,
	[Process] [varchar](50) NULL,
	[User] [varchar](50) NULL,
	[Machine] [varchar](50) NULL,
	[Message] [varchar](max) NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [IX_Diagnostics_Date] ON [dbo].[Diagnostics] 
(
	[Date] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  StoredProcedure [dbo].[Diagnostics_Insert]    Script Date: 02/21/2010 17:42:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[Diagnostics_Insert]	
	(
		@Date datetime,
		@Category varchar(50),
		@Severity int,
		@Process varchar(50),
		@User varchar(50),
		@Machine varchar(50),
		@message varchar(max)		
	)
AS
BEGIN
	SET NOCOUNT ON
	
	INSERT INTO Diagnostics
		(Date, Category, Severity, Process, [User], Machine, Message)
	VALUES
		(@Date, @Category, @Severity, @Process, @User, @Machine, @Message)

END
GO
/****** Object:  StoredProcedure [dbo].[Diagnostics_Get]    Script Date: 02/21/2010 17:42:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[Diagnostics_Get]
	(
		@StartDate DATETIME,
		@EndDate DATETIME,
		@Machine varchar(50) = null,
		@Message varchar(50) = null,
		@MinSeverity int = null,
		@Process varchar(50) = null,
		@MaxRecords int = 10000
	)
AS
BEGIN
	SET NOCOUNT ON
	
	IF @MaxRecords IS NOT NULL
		Set RowCount @MaxRecords

	SELECT
		Date,
		Category,
		Severity,
		Process,
		[User],
		Machine,
		Message
	FROM
		Diagnostics
	WHERE
		Date BETWEEN @StartDate and @EndDate
		AND (@Machine is null or Machine = @Machine)
		AND (@MinSeverity is null or Severity >= @MinSeverity)
		AND (@Process is null or Process = @Process)
		AND (@Message is null or Message like @Message)

END
GO

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


Written By
Software Developer
United Kingdom United Kingdom
I am a software developer originally from Auckland, New Zealand. I have lived and worked in London since 2005.

Comments and Discussions