File tree Expand file tree Collapse file tree
samples/LoggingReflectInsight
Console.ReflectInsightSample
WebApi.ReflectInsightSample
src/ReflectInsight.Extensions.Logging Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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" : {
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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" : {
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change 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" ,
You can’t perform that action at this time.
0 commit comments