Skip to content

Commit 64b2d1c

Browse files
committed
Minor caching issue with extensions.
1 parent b949da2 commit 64b2d1c

5 files changed

Lines changed: 36 additions & 6 deletions

File tree

samples/LoggingReflectInsight/Console.ReflectInsightSample/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dependencies": {
88
"Microsoft.Extensions.Logging": "1.1.0",
99
"Microsoft.Extensions.Logging.Console": "1.1.0",
10-
"ReflectInsight.Extensions.Logging": "1.1.1-*"
10+
"ReflectInsight.Extensions.Logging": "1.1.2-*"
1111
},
1212

1313
"frameworks": {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.Extensions.Logging;
3+
using ReflectInsight.Extensions.Logging;
4+
using System.Collections.Generic;
5+
6+
namespace WebApi.ExceptionInterceptSample.Controllers
7+
{
8+
[Route("api/[controller]")]
9+
public class ValuesController : Controller
10+
{
11+
private readonly ILogger _logger;
12+
13+
public ValuesController(ILoggerFactory loggerFactory)
14+
{
15+
_logger = loggerFactory.CreateLogger<ValuesController>();
16+
}
17+
18+
// GET: api/values
19+
[HttpGet]
20+
public IEnumerable<string> Get()
21+
{
22+
var result = new string[] { "value1", "value2" };
23+
24+
_logger.LogJSON("Test", result);
25+
26+
return result;
27+
}
28+
}
29+
}

samples/LoggingReflectInsight/WebApi.ReflectInsightSample/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"Microsoft.Extensions.Logging.Abstractions": "1.1.0",
99
"Microsoft.Extensions.Logging": "1.1.0",
1010
"Microsoft.Extensions.Configuration.Json": "1.1.0",
11-
"ReflectInsight.Extensions.Logging": "1.1.1-*"
11+
"ReflectInsight.Extensions.Logging": "1.1.2-*"
1212
},
1313

1414
"tools": {

src/ReflectInsight.Extensions.Logging/ReflectInsightLoggerExtensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@ private static IReflectInsight[] GetReflectInsights(ILogger logger)
6767
/// <returns></returns>
6868
private static IReflectInsight[] GetReflectInsightInstances(this ILogger logger)
6969
{
70-
return _riLoggers.GetOrAdd(logger.GetHashCode(), (key) =>
70+
var loggerType = logger.GetType();
71+
72+
return _riLoggers.GetOrAdd(loggerType.GetHashCode(), (key) =>
7173
{
7274
var riLoggers = (IReflectInsight[])null;
73-
var bindings = BindingFlags.NonPublic | BindingFlags.Instance;
74-
var loggerType = logger.GetType();
75+
var bindings = BindingFlags.NonPublic | BindingFlags.Instance;
7576

7677
var field = loggerType.GetField("_loggers", bindings);
7778
if(field == null)

src/ReflectInsight.Extensions.Logging/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.1.1",
2+
"version": "1.1.2",
33
"title": "ReflectInsight.Extensions.Logging",
44
"language": "en-US",
55
"description": "A ReflectInsight Logger implementation Microsoft.Extensions.Logging",

0 commit comments

Comments
 (0)