aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Web/Logging/AzureCloudLogger.cs
blob: 8cdc21d20fdf0030eae56ea9fc0d85064bbeda64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Logging;

namespace Tango.Web.Logging
{
    /// <summary>
    /// Represents an azure blob storage logger.
    /// </summary>
    /// <seealso cref="Tango.Logging.ILogger" />
    public class AzureCloudLogger : ILogger
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AzureCloudLogger"/> class.
        /// </summary>
        public AzureCloudLogger()
        {
            Enabled = true;
        }

        /// <summary>
        /// Called when a new log is available.
        /// </summary>
        /// <param name="log">The log.</param>
        public void OnLog(LogItemBase log)
        {
            switch (log.Category)
            {
                case LogCategory.Info:
                    Trace.TraceInformation(log.ToString());
                    break;
                case LogCategory.Warning:
                    Trace.TraceWarning(log.ToString());
                    break;
                case LogCategory.Error:
                    Trace.TraceError(log.ToString());
                    break;
                case LogCategory.Critical:
                    Trace.TraceError(log.ToString());
                    break;
                case LogCategory.Debug:
                    Trace.WriteLine(log.ToString());
                    break;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="T:Tango.Logging.ILogger" /> is enabled.
        /// </summary>
        public bool Enabled { get; set; }
    }
}