12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ShakerService.Tools
- {
- internal class Log
- {
- log4net.ILog log;
- private Log()
- {
- log = log4net.LogManager.GetLogger(typeof(Service));
- }
- static Log()
- {
- }
- public void Info(string msg)
- {
- log.Info($"{DateTime.Now}:{msg}");
- Debug(msg);
- }
- public void Debug(string msg)
- {
- #if DEBUG
- log.Debug($"{DateTime.Now}:{msg}");
- if(System.Console.IsOutputRedirected)
- {
- System.Diagnostics.Debug.WriteLine($"{DateTime.Now}:{msg}");
- }
- else
- {
- Console.WriteLine($"{DateTime.Now}:{msg}");
- }
- #endif
- }
- public void Error(string msg)
- {
- log.Error($"{DateTime.Now}:{msg}");
- Debug(msg);
- }
- public static Log Default { get; } = new Log();
- }
- }
|