Skip to content
This repository has been archived by the owner on Feb 2, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1 from kspearrin/rc2
Browse files Browse the repository at this point in the history
Updated library for RC2 compatibility
  • Loading branch information
withinfocus committed May 20, 2016
2 parents fd41254 + 9cb94eb commit cb874be
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 56 deletions.
2 changes: 1 addition & 1 deletion global.json
@@ -1,6 +1,6 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-rc1-update1"
"version": "1.0.0-preview1-002702"
}
}
Expand Up @@ -4,17 +4,15 @@
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>

<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>e88c4a16-6b32-4e31-a23c-4afbcfa0bb5d</ProjectGuid>
<RootNamespace>Loggr.Extensions.Logging.Console</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>

<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
4 changes: 2 additions & 2 deletions sample/Loggr.Extensions.Logging.Console/Program.cs
Expand Up @@ -14,10 +14,10 @@ public static void Main( string[] args )
logger.LogCritical( "This is critical", new Exception( "Critical stuff going down" ) );
logger.LogError( "This is an error", new Exception( "Erroneous stuff all over the place" ) );
logger.LogInformation( "This is information" );
logger.LogVerbose( "This is verbose" );
logger.LogTrace( "This is trace" );
logger.LogWarning( "This is a warning" );

using( logger.BeginScopeImpl( "Main" ) )
using( logger.BeginScope( "Main" ) )
{
logger.LogInformation( "This is information in scope" );
}
Expand Down
30 changes: 17 additions & 13 deletions sample/Loggr.Extensions.Logging.Console/project.json
@@ -1,28 +1,32 @@
{
"version": "1.0.0-rc1-final-*",
"version": "1.0.0-rc2-final",
"description": "Loggr.Extensions.Logging console application",
"authors": [ "mbishopim3" ],
"tags": [ "" ],
"projectUrl": "https://github.com/imobile3/Loggr.Extensions.Logging",
"licenseUrl": "",

"compilationOptions": {
"emitEntryPoint": true
"packOptions": {
"tags": [ "loggr" ],
"projectUrl": "https://github.com/imobile3/Loggr.Extensions.Logging",
"iconUrl": "http://static.loggr.net/1/images/nuget/logo.png"
},

"dependencies": {
"Loggr.Extensions.Logging": "1.0.0-rc1-final-*"
},

"commands": {
"Loggr.Extensions.Logging.Console": "Loggr.Extensions.Logging.Console"
"Loggr.Extensions.Logging": "1.0.0-rc2-final"
},

"frameworks": {
"dnx451": {
"netframework451": {
"imports": [ "dnx451" ],
"frameworkAssemblies": {
"System.Runtime": ""
}
}
},

"runtimeOptions": {
"gcServer": false,
"gcConcurrent": true
},

"buildOptions": {
"emitEntryPoint": true
}
}
8 changes: 4 additions & 4 deletions src/Loggr.Extensions.Logging/Loggr.Extensions.Logging.xproj
Expand Up @@ -4,18 +4,18 @@
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>0af6cb38-184b-4895-985f-35d9c4fac02a</ProjectGuid>
<RootNamespace>Loggr.Extensions.Logging</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
31 changes: 11 additions & 20 deletions src/Loggr.Extensions.Logging/LoggrLogger.cs
Expand Up @@ -5,7 +5,7 @@ namespace Loggr.Extensions.Logging
{
public class LoggrLogger : ILogger
{
private readonly Func<string, LogLevel, int, bool> m_filter;
private readonly Func<string, LogLevel, EventId, bool> m_filter;
private readonly string m_name;
private readonly LogClient m_client;
private readonly string m_source;
Expand All @@ -14,15 +14,15 @@ public LoggrLogger( LogClient client, string name, string source )
: this( client, name, source, null )
{ }

public LoggrLogger( LogClient client, string name, string source, Func<string, LogLevel, int, bool> filter )
public LoggrLogger( LogClient client, string name, string source, Func<string, LogLevel, EventId, bool> filter )
{
m_client = client;
m_name = name;
m_source = source;
m_filter = filter;
}

public IDisposable BeginScopeImpl( object state )
public IDisposable BeginScope<TState>( TState state )
{
return null;
}
Expand All @@ -32,12 +32,12 @@ public bool IsEnabled( LogLevel logLevel )
return true;
}

public bool IsEnabled( LogLevel logLevel, int eventId )
public bool IsEnabled( LogLevel logLevel, EventId eventId )
{
return m_filter == null || m_filter( m_name, logLevel, eventId );
}

public void Log( LogLevel logLevel, int eventId, object state, Exception exception, Func<object, Exception, string> formatter )
public void Log<TState>( LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter )
{
if( !IsEnabled( logLevel, eventId ) )
{
Expand All @@ -49,22 +49,13 @@ public void Log( LogLevel logLevel, int eventId, object state, Exception excepti
return;
}

var values = state as ILogValues;
string message;

if( formatter != null )
{
message = formatter( state, null );
}
else if( values != null )
if( formatter == null )
{
message = LogFormatter.FormatLogValues( values );
}
else
{
message = LogFormatter.Formatter( state, null );
throw new ArgumentNullException( nameof( formatter ) );
}

var message = formatter( state, exception );

if( string.IsNullOrWhiteSpace( message ) )
{
message = string.Empty;
Expand Down Expand Up @@ -108,8 +99,8 @@ private string GetLogLevel( LogLevel logLevel )
{
switch( logLevel )
{
case LogLevel.Verbose:
return "verbose";
case LogLevel.Trace:
return "trace";
case LogLevel.Debug:
return "debug";
case LogLevel.Information:
Expand Down
Expand Up @@ -10,7 +10,7 @@ public static ILoggerFactory AddLoggr( this ILoggerFactory factory, string logKe
return AddLoggr( factory, LogLevel.Information, logKey, apiKey, source );
}

public static ILoggerFactory AddLoggr( this ILoggerFactory factory, Func<string, LogLevel, int, bool> filter, string logKey, string apiKey, string source = null )
public static ILoggerFactory AddLoggr( this ILoggerFactory factory, Func<string, LogLevel, EventId, bool> filter, string logKey, string apiKey, string source = null )
{
factory.AddProvider( new LoggrLoggerProvider( filter, logKey, apiKey, source ) );
return factory;
Expand Down
4 changes: 2 additions & 2 deletions src/Loggr.Extensions.Logging/LoggrLoggerProvider.cs
Expand Up @@ -5,11 +5,11 @@ namespace Loggr.Extensions.Logging
{
public class LoggrLoggerProvider : ILoggerProvider
{
private readonly Func<string, LogLevel, int, bool> m_filter;
private readonly Func<string, LogLevel, EventId, bool> m_filter;
private readonly LogClient m_logClient;
private readonly string m_source;

public LoggrLoggerProvider( Func<string, LogLevel, int, bool> filter, string logKey, string apiKey, string source = null )
public LoggrLoggerProvider( Func<string, LogLevel, EventId, bool> filter, string logKey, string apiKey, string source = null )
{
m_filter = filter;
m_logClient = new LogClient( logKey, apiKey );
Expand Down
20 changes: 14 additions & 6 deletions src/Loggr.Extensions.Logging/project.json
@@ -1,20 +1,28 @@
{
"version": "1.0.1-rc1-final-*",
"version": "1.0.0-rc2-final",
"title": "Loggr.Extensions.Logging",
"description": "Loggr provider for Microsoft.Extensions.Logging",
"authors": [ "mbishopim3" ],
"tags": [ "loggr dnx" ],
"projectUrl": "https://github.com/imobile3/Loggr.Extensions.Logging",
"iconUrl": "http://static.loggr.net/1/images/nuget/logo.png",
"copyright": "2015 iMobile3, LLC",
"packOptions": {
"tags": [ "loggr" ],
"projectUrl": "https://github.com/imobile3/Loggr.Extensions.Logging",
"iconUrl": "http://static.loggr.net/1/images/nuget/logo.png"
},
"frameworks": {
"dnx451": {
"netframework451": {
"imports": [ "dnx451" ],
"frameworkAssemblies": {
"System.Runtime": ""
}
}
},
"dependencies": {
"Microsoft.Extensions.Logging": "1.0.0-rc1-final"
"Microsoft.Extensions.Logging": "1.0.0-rc2-final"
},

"runtimeOptions": {
"gcServer": false,
"gcConcurrent": true
}
}

0 comments on commit cb874be

Please sign in to comment.