PageRenderTime 5ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/NUnit/core/LogCapture.cs

#
C# | 48 lines | 32 code | 6 blank | 10 comment | 6 complexity | 1b66ce80814ceb4b3288c26904eb5b57 MD5 | raw file
 1// ****************************************************************
 2// Copyright 2008, Charlie Poole
 3// This is free software licensed under the NUnit license. You may
 4// obtain a copy of the license at http://nunit.org.
 5// ****************************************************************
 6
 7using System.Collections.Specialized;
 8using System.Configuration;
 9
10namespace NUnit.Core
11{
12    public abstract class LogCapture : TextCapture
13    {
14        private string defaultThreshold;
15
16        /// <summary>
17        /// The default threshold for log capture
18        /// is read from the config file. If not
19        /// found, we use "Error".
20        /// </summary>
21        public override string DefaultThreshold
22        {
23            get
24            {
25                if (defaultThreshold == null)
26                {
27                    defaultThreshold = "Error";
28
29                    NameValueCollection settings = (NameValueCollection)
30#if NET_2_0
31                        ConfigurationManager.GetSection("NUnit/TestRunner");
32#else
33                        ConfigurationSettings.GetConfig("NUnit/TestRunner");
34#endif
35
36                    if (settings != null)
37                    {
38                        string level = settings["DefaultLogThreshold"];
39                        if (level != null)
40                            defaultThreshold = level;
41                    }
42                }
43
44                return defaultThreshold;
45            }
46        }
47    }
48}