Permalink
Browse files

Logging to tab with configuration options

  • Loading branch information...
1 parent 0863873 commit 668e579774096d161b993d2d2989815338d9d594 @johnzablocki johnzablocki committed Mar 6, 2013
Showing 308 changed files with 161,326 additions and 0 deletions.
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{543E589B-B021-4E59-82FE-EDA6797F3266}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Couchbase.Glimpse</RootNamespace>
+ <AssemblyName>Couchbase.Glimpse</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Couchbase">
+ <HintPath>..\packages\CouchbaseNetClient.1.2.2\lib\net40\Couchbase.dll</HintPath>
+ </Reference>
+ <Reference Include="Enyim.Caching">
+ <HintPath>..\packages\CouchbaseNetClient.1.2.2\lib\net40\Enyim.Caching.dll</HintPath>
+ </Reference>
+ <Reference Include="Enyim.Caching.Log4NetAdapter">
+ <HintPath>..\packages\CouchbaseNetClient.1.2.2\lib\net40\Enyim.Caching.Log4NetAdapter.dll</HintPath>
+ </Reference>
+ <Reference Include="Enyim.Caching.NLogAdapter">
+ <HintPath>..\packages\CouchbaseNetClient.1.2.2\lib\net40\Enyim.Caching.NLogAdapter.dll</HintPath>
+ </Reference>
+ <Reference Include="Glimpse.Core">
+ <HintPath>..\packages\Glimpse.1.0.1\lib\net40\Glimpse.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="Hammock">
+ <HintPath>..\packages\Hammock.1.2.9\lib\4.0\Hammock.dll</HintPath>
+ </Reference>
+ <Reference Include="Hammock.ClientProfile">
+ <HintPath>..\packages\Hammock.1.2.9\lib\4.0\Hammock.ClientProfile.dll</HintPath>
+ </Reference>
+ <Reference Include="log4net">
+ <HintPath>..\packages\CouchbaseNetClient.1.2.2\lib\net40\log4net.dll</HintPath>
+ </Reference>
+ <Reference Include="Newtonsoft.Json">
+ <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ <Reference Include="NLog">
+ <HintPath>..\packages\CouchbaseNetClient.1.2.2\lib\net40\NLog.dll</HintPath>
+ </Reference>
+ <Reference Include="RestSharp">
+ <HintPath>..\packages\CouchbaseNetClient.1.2.2\lib\net40\RestSharp.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Web" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="CouchbaseTab.cs" />
+ <Compile Include="Logging\GlimpseLogger.cs" />
+ <Compile Include="Logging\GlimpseLogConfiguration.cs" />
+ <Compile Include="Logging\GlimpseLogFactory.cs" />
+ <Compile Include="Logging\GlimpseLog.cs" />
+ <Compile Include="Logging\GlimpseLogRow.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,60 @@
+/**
+ * Copyright (c) 2012 Couchbase, Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Glimpse.Core.Extensibility;
+using Couchbase.Glimpse.Logging;
+
+namespace Couchbase.Glimpse
+{
+ public class CouchbaseTab : TabBase
+ {
+ public override object GetData(ITabContext context)
+ {
+ var data = new List<object[]> { new[] { "Level", "Timestamp", "Source", "Message", "Exception", "Thread" } };
+ var debug = new List<object[]> { };
+
+ Action<Dictionary<string, List<GlimpseLogRow>>> addData = (d) =>
+ {
+ foreach (var key in d.Keys)
+ {
+ d[key].ForEach(a =>
+ {
+ var exCol = new List<object> { };
+ if (a.Exception != null)
+ {
+ exCol.Add(new object[] { "Message", "StackTrace" });
+ exCol.Add(new object[] { a.Exception.Message, a.Exception.StackTrace });
+ }
+ data.Add(new object[] { a.Level, a.Timestamp, a.Source, a.Message, exCol, a.ThreadId });
+ });
+ }
+ };
+
+ addData(GlimpseLog.PreHttpContextRows);
+ addData(GlimpseLog.Rows);
+ GlimpseLog.PreHttpContextRows.Clear();
+ return data;
+ }
+
+ public override string Name
+ {
+ get { return "Couchbase"; }
+ }
+
+ }
+}
@@ -0,0 +1,71 @@
+/**
+ * Copyright (c) 2012 Couchbase, Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Web;
+
+namespace Couchbase.Glimpse.Logging
+{
+ public static class GlimpseLog
+ {
+ private static Dictionary<string, List<GlimpseLogRow>> _preHttpContextRows= new Dictionary<string, List<GlimpseLogRow>>();
+
+ public static Dictionary<string, List<GlimpseLogRow>> Rows
+ {
+ get { return getRows(); }
+ }
+
+ public static Dictionary<string, List<GlimpseLogRow>> PreHttpContextRows
+ {
+ get { return _preHttpContextRows; }
+ }
+
+ public static void AddRow(GlimpseLogRow row)
+ {
+ //Condition when client is created in a constructor
+ if (HttpContext.Current == null)
+ {
+ if (!_preHttpContextRows.ContainsKey(row.Level))
+ {
+ _preHttpContextRows[row.Level] = new List<GlimpseLogRow>();
+ }
+ _preHttpContextRows[row.Level].Add(row);
+ return;
+ }
+
+ var rows = getRows();
+ if (! rows.ContainsKey(row.Level))
+ {
+ rows[row.Level] = new List<GlimpseLogRow>();
+ }
+ rows[row.Level].Add(row);
+ }
+
+ private static Dictionary<string, List<GlimpseLogRow>> getRows()
+ {
+ var rows = HttpContext.Current.Items["CB:Messages"] as Dictionary<string, List<GlimpseLogRow>>;
+ if (rows == null)
+ {
+ rows = new Dictionary<string, List<GlimpseLogRow>>();
+ HttpContext.Current.Items["CB:Messages"] = rows;
+ }
+ return rows;
+ }
+
+
+ }
+}
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2012 Couchbase, Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Couchbase.Glimpse.Logging
+{
+ public sealed class GlimpseLogConfiguration
+ {
+ public bool IsDebugEnabled { get; set; }
+
+ public bool IsInfoEnabled { get; set; }
+
+ public bool IsWarnEnabled { get; set; }
+
+ public bool IsErrorEnabled { get; set; }
+
+ public bool IsFatalEnabled { get; set; }
+
+ private List<string> _sourceWhiteList = new List<string>();
+ public List<string> SourceWhiteList { get { return _sourceWhiteList; } }
+ }
+}
@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2012 Couchbase, Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Enyim.Caching;
+
+namespace Couchbase.Glimpse.Logging
+{
+ public class GlimpseLogFactory : ILogFactory
+ {
+ public ILog GetLogger(Type type)
+ {
+ return new GlimpseLogger(type.Name);
+ }
+
+ public ILog GetLogger(string name)
+ {
+ return new GlimpseLogger(name);
+ }
+ }
+}
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2012 Couchbase, Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Couchbase.Glimpse.Logging
+{
+ public class GlimpseLogRow
+ {
+ public string Level { get; set; }
+
+ public DateTime Timestamp { get; set; }
+
+ public Exception Exception { get; set; }
+
+ public string Message { get; set; }
+
+ public string Source { get; set; }
+
+ public int ThreadId { get; set; }
+ }
+}
Oops, something went wrong.

0 comments on commit 668e579

Please sign in to comment.