Exemple #1
0
        ////CONSTRUCTOR:
        //static XLogging()
        //{
        //   if (_Ptr == null)
        //      _Ptr = new XLogging();
        //}

        //public static XLogging Log { get { return _Ptr; } }


        public void Init(string psPath, string psLogFilePfx, XLogLevel pLevel, XLogInfo pLogInfo)
        {
            _xlogLevel = pLevel;
            _xlogInfo  = pLogInfo;

            SetLogPath(psPath, psLogFilePfx);
        }
Exemple #2
0
 public void Log(XLogLevel level, string msg, params object[] args)
 {
     if (level >= LogLevel)
     {
         var fmsg = string.Format("<{0}> {1}\n", DateTime.Now.ToString("HH:mm:ss"), string.Format(msg, args));
         InnerLog(level, fmsg);
     }
 }
Exemple #3
0
        /// <summary>
        /// Logs a line in xbmc.log
        /// </summary>
        /// <param name="message"></param>
        public void Log(string message, XLogLevel level)
        {
            var args = new JObject {
                new JProperty("volume", message), new JProperty("level", level.ToString())
            };

            Client.GetData("XBMC.Log", args, null, null);
        }
Exemple #4
0
        public void Write(XLogLevel pLevel, int pIndent, string psModule, string psMessage)
        {
            if ((int)pLevel <= (int)_xlogLevel)
            {
                string sFmtMsg = GenerateRowPrefix(_xlogInfo, pLevel, "") + GetIndent(pIndent) + psMessage;

                EnqueueLogEntry(sFmtMsg);
            }
        }
Exemple #5
0
 private void Log(XLogLevel level, string prefix, string format, params object[] args)
 {
     if ((int)level >= (int)LogLevel)
     {
         log.Append(prefix);
         log.Append('-', (int)Indent * 4);
         log.AppendFormat(format, args);
         log.AppendLine();
     }
 }
Exemple #6
0
 private void Log(XLogLevel level, string prefix, string format, params object[] args)
 {
     if ((int)level >= (int)LogLevel)
     {
         var msg = new StringBuilder(prefix)
                   .Append('-', (int)Indent * 4)
                   .AppendFormat(format, args)
                   .AppendLine()
                   .ToString();
         textBox.AppendText(msg);
     }
 }
Exemple #7
0
 internal void InnerLog(XLogLevel level, string msg)
 {
     switch (level)
     {
         case XLogLevel.Debug:
         case XLogLevel.Info:
             UnityEngine.Debug.Log(msg);
             break;
         case XLogLevel.Warn:
             UnityEngine.Debug.LogWarning(msg);
             break;
         case XLogLevel.Error:
             UnityEngine.Debug.LogError(msg);
             break;
     }
 }
Exemple #8
0
        private string GenerateRowPrefix(XLogInfo pInfoParams, XLogLevel pLevel, string psModule)
        {
            StringBuilder sb = new StringBuilder();


            if ((pInfoParams & XLogInfo.LogDate) == XLogInfo.LogDate)
            {
                sb.AppendFormat("{0:yyyy-MM-dd}", DateTime.Today);
            }

            if ((pInfoParams & XLogInfo.LogTime) == XLogInfo.LogTime)
            {
                if (sb.Length > 0)
                {
                    sb.Append(" ");
                }
                sb.AppendFormat("{0:HH:mm:ss}", DateTime.Now);
            }

            if ((pInfoParams & XLogInfo.LogMSec) == XLogInfo.LogMSec)
            {
                if (sb.Length > 0)
                {
                    sb.Append(".");
                }
                sb.AppendFormat("{0:000}", DateTime.Now.Millisecond);
            }

            if ((pInfoParams & XLogInfo.User) == XLogInfo.User)
            {
                if (sb.Length > 0)
                {
                    sb.Append(" - ");
                }
                sb.AppendFormat("{0:-15}", GetCurrentUserID());
            }

            //TODO -- add session info
            if ((pInfoParams & XLogInfo.Level) == XLogInfo.Level)
            {
                if (sb.Length > 0)
                {
                    sb.AppendFormat(" [{0:-10}]", pLevel.ToString());
                }
                else
                {
                    sb.AppendFormat("{0:-10}", pLevel.ToString());
                }
            }

            if ((pInfoParams & XLogInfo.Module) == XLogInfo.Module)
            {
                if (sb.Length > 0)
                {
                    sb.Append(" - ");
                }
                sb.AppendFormat("{0:-15}", psModule);
            }

            return(sb.ToString());
        }
Exemple #9
0
        //public void WriteExceptionLogEntry(int piDetail, string psModule, Exception ex)
        //{
        //    try
        //    {
        //        if (_bLoggingEnabled)
        //        {
        //            if ((int)piDetail <= (int)_iLevel)
        //            {

        //                string sUserID = GetCurrentUserID();
        //                string sDetLabel = GetDetailLabel(piDetail);

        //                string sFmtMsg = string.Format("{0:HH:mm:ss}.{1:000} {2,-10} [{4,-5}] {3,-50} : ", DateTime.Now, DateTime.Now.Millisecond, sUserID, psModule, sDetLabel);

        //                //                  string sFmtMsg = string.Format("{0:hh:mm:ss}.{1:000} - {2,-10} - {3,-50} - ", DateTime.Now, DateTime.Now.Millisecond, sUserID, psModule);

        //                EnqueueLogEntry(string.Format("{0} Error:{1}", sFmtMsg, ex.Message));
        //                EnqueueLogEntry(string.Format("{0} Source:{1}", sFmtMsg, ex.Source));
        //                EnqueueLogEntry(string.Format("{0} Stack:{1}", sFmtMsg, ex.StackTrace));

        //                if (ex.Data != null)
        //                {
        //                    if (ex.Data.Count > 0)
        //                    {
        //                        EnqueueLogEntry(string.Format("{0} --- Exception Data:", sFmtMsg));

        //                        for (int i = 0; i < ex.Data.Count; i++)
        //                            EnqueueLogEntry(string.Format("{0} Data#{1}: {2}", sFmtMsg, i, ex.Data));
        //                    }
        //                }

        //                if (ex.InnerException != null)
        //                {
        //                    EnqueueLogEntry(string.Format("{0} --- Inner Exception:", sFmtMsg));

        //                    EnqueueLogEntry(string.Format("{0} Inner Error:{1}", sFmtMsg, ex.InnerException.Message));
        //                    EnqueueLogEntry(string.Format("{0} Inner Source:{1}", sFmtMsg, ex.InnerException.Source));
        //                    EnqueueLogEntry(string.Format("{0} Inner Stack:{1}", sFmtMsg, ex.InnerException.StackTrace));
        //                }
        //            }
        //        }
        //    }
        //    catch { }

        //}


        public void Write(XLogLevel pLevel, XLogIndent pIndent, string psModule, string psMessage)
        {
            this.Write(pLevel, (int)pIndent, psModule, psMessage);
        }
Exemple #10
0
 public XLog(XLogLevel logLevel = XLogLevel.Warn)
 {
     LogLevel = logLevel;
 }
Exemple #11
0
        /// <summary>
        /// Logs a line in xbmc.log
        /// </summary>
        /// <param name="message"></param>
        public void Log(string message, XLogLevel level)
        {
            var args = new JObject { new JProperty("volume", message), new JProperty("level", level.ToString()) };

             Client.GetData("XBMC.Log", args, null, null);
        }