1 /// Copyright 2016 by Samsung Electronics, Inc.,
3 /// This software is the confidential and proprietary information
4 /// of Samsung Electronics, Inc. ("Confidential Information"). You
5 /// shall not disclose such Confidential Information and shall use
6 /// it only in accordance with the terms of the license agreement
7 /// you entered into with Samsung.
12 using System.Diagnostics;
17 /// Directs tracing or debugging output to Tizen logging system.
19 public class LogTraceListener : TraceListener
21 private string _tagName = null;
22 private readonly StringBuilder _buf = new StringBuilder();
25 /// Initializes a new instance of the LogTraceListener class, using the specfied tag name of the logging system.
27 /// <param name="tag">The tag name of the log message.</param>
28 public LogTraceListener(string tag) : base("DLOG")
34 /// The tag name of the log message.
38 get { return _tagName; }
39 set { _tagName = value; }
42 private void WriteImpl(string message)
52 /// Writes an error message to the logging system.
54 /// <param name="message">The error message to print.</param>
55 public override void Fail(string message)
61 /// Writes an error message and a detailed error message to the logging system.
63 /// <param name="message">The error message to print.</param>
64 /// <param name="detailMessage">The detailed error message to print.</param>
65 public override void Fail(string message, string detailMessage)
67 StringBuilder failBuf = new StringBuilder();
68 failBuf.Append("Fail: ");
69 failBuf.Append(message);
70 if (!String.IsNullOrEmpty(detailMessage))
73 failBuf.Append(detailMessage);
75 Log.Error(_tagName, failBuf.ToString(), null);
79 /// Writes a log message to the logging system.
81 /// <param name="message">The log message to print.</param>
82 public override void Write(string message)
88 /// Writes a log message followed by the current line terminator to the logging system.
90 /// <param name="message">The log message to print.</param>
91 public override void WriteLine(string message)
93 WriteImpl(message + Environment.NewLine);
99 /// Causes buffered data to be written to the logging system.
101 public override void Flush()
103 Log.Debug(_tagName, _buf.ToString(), null);