Skip to main content

Code

Base styles for code snippets.

Example

public class RaygunLoggerProvider : ILoggerProvider
{
    private readonly RaygunConfiguration _config;
    private readonly ConcurrentDictionary<string, RaygunLogger> _loggers = new ConcurrentDictionary<string, RaygunLogger>();
    
    public RaygunLoggerProvider(RaygunConfiguration config)
    {
        _config = config;
    }
    
    public void Dispose()
    {
        _loggers.Clear();
    }
    
    public ILogger CreateLogger(string categoryName)
    {
        return _loggers.GetOrAdd(categoryName, x => new RaygunLogger(categoryName, _config));
    }
}
<pre>

<code>
public class RaygunLoggerProvider : ILoggerProvider
{
private readonly RaygunConfiguration _config;
private readonly ConcurrentDictionary&lt;string, RaygunLogger&gt; _loggers = new ConcurrentDictionary&lt;string, RaygunLogger&gt;();

public RaygunLoggerProvider(RaygunConfiguration config)
{
_config = config;
}

public void Dispose()
{
_loggers.Clear();
}

public ILogger CreateLogger(string categoryName)
{
return _loggers.GetOrAdd(categoryName, x =&gt; new RaygunLogger(categoryName, _config));
}
}
</code>
</pre>