public static bool Write(CSSDataContext db, LogType type, string message, bool submit)
        {
            try
            {
                db.Logs.InsertOnSubmit(new Log()
                {
                    DateOccurred = DateTime.Now,
                    Message     = message,
                    Type        = (byte)type
                });

                if (submit)
                    db.SubmitChanges();

                Console.WriteLine(String.Format("{0}: {1} {2}", DateTime.Now, type.ToString(), message));

                return true;
            }
            catch(Exception error)
            {
                var errorMessage = new StringBuilder()
                    .AppendLine("Failed to write data to log:")
                    .Append("Type: ").AppendLine(type.ToString())
                    .Append("Message: ").AppendLine(message);

                Debug.WriteLine(errorMessage);

                Error.Write(db, new Exception(errorMessage.ToString(), error), submit);
                return false;
            }
        }
Esempio n. 2
0
        private static string GetMessage(LogType type, string message, Exception exception = null)
        {
            string messageToLog = string.Empty;
            if (exception != null)
            {
                messageToLog = string.Format(LogMessageException,
                    GetTimeStamp(),
                    type.ToString(),
                    message,
                    exception.GetType(),
                    exception.Message,
                    (exception.InnerException != null && exception.InnerException.Message != null) ? exception.InnerException.Message : "None",
                    exception.Source
                    );
            }
            else
            {
                messageToLog = string.Format(LogMessageBrief,
                    GetTimeStamp(),
                    type.ToString(),
                    message
                    );
            }

            return messageToLog;
        }
Esempio n. 3
0
        public void Init(LogType type)
        {
            MyType = type;
            isInit = true;

            FILENAME = LOG_FOLDER + "\\" + MyType.ToString() + "_" + BASE_FILENAME;
            SPOOLED_FILENAME = MyType.ToString() + "_" + BASE_SPOOLED_FILENAME;
        }
Esempio n. 4
0
    void MyCallBack(string logString, string stackTrace, LogType type)
    {
        output = logString;
        stack = stackTrace;
        logtype = type.ToString();

    }
Esempio n. 5
0
        private static void log(Type callerType, LogType logType, params object[] message)
        {
            var time = DateTime.Now;
            var elapsed = lastLogTime != null ? DateTime.Now - (DateTime)lastLogTime : TimeSpan.Zero;
            lastLogTime = time;

            string strTime = time.ToString("HH:mm:ss.fff");
            string prefix = "[" + logType.ToString().ToUpper() + "] " + elapsed.TotalMilliseconds + " ms ";
            string strMessage = String.Join("\t", message);

            ConsoleColor previousBackground = Console.BackgroundColor;
            ConsoleColor previousForeground = Console.ForegroundColor;
            ConsoleColor foregroundColor = colors[logType].Item1;
            ConsoleColor backgroundColor = colors[logType].Item2;

            if (Console.ForegroundColor != foregroundColor)
                Console.ForegroundColor = foregroundColor;

            if (Console.BackgroundColor != backgroundColor)
                Console.BackgroundColor = backgroundColor;

            Console.Write(prefix);

            string rightAlignedText = callerType.Name;
            Console.Write(" ".Repeat(Console.BufferWidth - Console.CursorLeft - rightAlignedText.Length));
            Console.Write(rightAlignedText);

            Console.BackgroundColor = previousBackground;
            Console.ForegroundColor = previousForeground;

            Console.WriteLine(strMessage + "\n");
        }
 private void BroadcastLog(String condition, String stackTrace, LogType type)
 {
     Send("log", new JObject {
         { "type", type.ToString().ToLower() },
         { "message", condition }
     });
 }
Esempio n. 7
0
 private void Application_logMessageReceived(string _log, string _stack, LogType _type)
 {
     if (_type == LogType.Exception || _type == LogType.Error)
     {                                                                           
         sw.WriteLine(System.DateTime.Now.ToString() + " | " + _log + " | " + _stack + " | " + _type.ToString());
     }
 }
Esempio n. 8
0
        public static void WriteLog(LogType type, string log)
        {
            if(_isInWorkflow){
                _stopWatch.Stop();
            }
            StringBuilder _sb = new StringBuilder();
            _sb.Append("===========================================================================================");
            _sb.Append(DateTime.Now.ToString("HH:mm:ss.fff"));
            if (_isInWorkflow) {
                _sb.Append(" |");
                _sb.Append(" " + _stopWatch.ElapsedMilliseconds);
                _sb.Append(" (+" + (_stopWatch.ElapsedMilliseconds - _timeHold) + ")");
                _sb.Append(" |");
                _sb.Append(" " + _stopWatch.ElapsedTicks);
                _sb.Append(" (+" + (_stopWatch.ElapsedTicks - _ticksHold) + ")");
            }
            _sb.AppendLine();
            _sb.AppendLine(log);
            string filepath;
            filepath = Xy.AppSetting.LogDir + type.ToString() + "-" + DateTime.Now.ToString("yyyy-MM-dd") + ".log";

            System.IO.FileStream _fs = System.IO.File.Open(filepath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
            try {
                byte[] _log = System.Text.Encoding.UTF8.GetBytes(_sb.ToString());
                _fs.Write(_log, 0, _log.Length);
                _fs.Flush();
            } finally {
                _fs.Close();
            }
            if (_isInWorkflow) {
                _timeHold = _stopWatch.ElapsedMilliseconds;
                _ticksHold = _stopWatch.ElapsedTicks;
                _stopWatch.Start();
            }
        }
Esempio n. 9
0
 public static void Log(string s, LogType type)
 {
     if (Silence) return;
     ConsoleColor messageColor = ConsoleColor.White;
     switch (type)
     {
         case LogType.Message:
             messageColor = ConsoleColor.White;
             break;
         case LogType.Error:
             messageColor = ConsoleColor.Red;
             break;
         case LogType.Warning:
             messageColor = ConsoleColor.Yellow;
             break;
         case LogType.Fatal:
             messageColor = ConsoleColor.DarkRed;
             break;
         case LogType.Success:
             messageColor = ConsoleColor.Green;
             break;
     }
     Console.ForegroundColor = messageColor;
     Console.Write("[" + type.ToString() + "] ");
     Console.ForegroundColor = ConsoleColor.Gray;
     Console.WriteLine(s);
     //Logs.Add("<span style='color:" + messageColor.ToString().ToLower() + ";'>[" + type.ToString() + "]</span> " + s + "<br/>");
     if (type == LogType.Fatal)
     {
         Console.WriteLine("Press any key to continue...");
         Logger.PushLogs();
         Console.Read();
         Environment.Exit(0);
     }
 }
Esempio n. 10
0
	void LogHandler(string condition, string stack, LogType type)
	{
		if (LogEvent != null)
			LogEvent(condition, stack, type);

		if (logLines == null)
			logLines = new List<string>(maxLogLine);
		
		if (logLines.Count >= maxLogLine)
			logLines.RemoveAt(0);
		
		string color = "#FFFFFF";
		
		if (type == LogType.Warning)
		{
			color = "#CCCC00";
		}
		else if (type == LogType.Error || type == LogType.Exception)
		{
			color = "#CC0000";
			condition += stack;
		}

		string logText = string.Format("{0} {1} {2}", type.ToString(), DateTime.Now.ToString("HH:mm:ss.ff"), condition);

		logLines.Add(string.Format("<color={0}>{1}</color>", color, logText));

		hasNewMessage = true;
	}
Esempio n. 11
0
    public void Write(string logfilename, string log, LogType lt)
    {
#if UNITY_IPHONE || UNITY_ANDROID
        return;
#endif
        string filePathName = WriteFile(logfilename);

        FileStream fs = new FileStream(filePathName, FileMode.Append);
        StreamWriter sw = new StreamWriter(fs);
        //开始写入 
        sw.WriteLine("");
        //
        string str = "[";
        str += System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");//默认当天时间。
        str += "]";
        str += "\t";
        str += lt.ToString();
        str += "\t";
        str += log;

        sw.Write(str);
        //清空缓冲区 
        sw.Flush();
        //关闭流 
        sw.Close();
        fs.Close();
    }
Esempio n. 12
0
        public static void Log(String msg, LogType type)
        {
            lock (loggerLock)
            {
                try
                {
                    if (LogLevel >= (int)type)
                    {
                        String formatedMsg = "[" + DateTime.Now.ToUniversalTime() +
                            "][" + type.ToString() + "] " + msg + "\n";

            #if DEBUG
                        Console.Write(formatedMsg);
            #endif
                        StreamWriter fs = new StreamWriter(new FileStream(loggerFile, FileMode.Append));
                        fs.Write(formatedMsg);
                        fs.Flush();
                        fs.Close();
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("Ocorreu um erro ao registrar a seguinte mensagem:\n" + msg + "\n\nErro:" + e.ToString());
                }
            }
        }
 void Log (LogType type,  string message)
 {
     using (var streamWriter = new StreamWriter(dir + _name, true))
     {
         streamWriter.WriteLine(DateTime.Now.ToLongTimeString() + " | " + type.ToString().ToUpper() + " | " + message);
     }
 }
Esempio n. 14
0
        public void LogEvent(string eventSource, LogType logType, string logContent)
        {
            try
            {
                lock (s_locker)
                {
                    string commandText = @"INSERT INTO [dbo].[SYSTEM_EVENT_LOG]
                        (
                            [SYSTEM_INSERT_DATETIME],
                            [SYSTEM_STATUS],
                            [EVENT_SOURCE],
                            [LOG_TYPE],
                            [LOG_CONTENT]
                        )
                        VALUES
                        (
                            GETDATE(),
                            0,
                            @EVENT_SOURCE,
                            @LOG_TYPE,
                            @LOG_CONTENT
                        )";

                    this.dbHelper.ExecuteNonQuery(commandText, new { EVENT_SOURCE = eventSource, LOG_TYPE = logType.ToString(), LOG_CONTENT = logContent });
                }
            }
            catch { }
        }
Esempio n. 15
0
        public static void Log( string text, string stackTrace, LogType type = LogType.Log )
        {
            if (!Config.RemoteLoggerEnabled) return;

            string t_url = Config.RemoteLoggerURL + "?t=" + type.ToString() + "&p=" + Util.Storage.UrlEncode ( text ) + "&s=" + Util.Storage.UrlEncode ( stackTrace );
            Util.Storage.WWWSend ( t_url );
        }
Esempio n. 16
0
        public void WriteLine(LogType t, string fmt, params object[] args)
        {
            var gstr = "";
            switch (t)
            {
                case LogType.Debug:
                case LogType.Error:
                case LogType.Exception:
                case LogType.Warning:
                    gstr = t.ToString() + "> ";
                    break;
                case LogType.Notice:
                    break;
                default:
                    throw new NotImplementedException();
            }

            if (logTextBox.InvokeRequired)
            {
                Invoke((MethodInvoker)delegate ()
                {
                    logTextBox.AppendText(String.Format("{0}{1}{2}{3}", DateTime.Now.ToString("hh:mm:ss "), gstr, String.Format(fmt, args), Environment.NewLine));
                });
            }
            else
            {
                logTextBox.AppendText(String.Format("{0}{1}{2}{3}", DateTime.Now.ToString("hh:mm:ss "), gstr, String.Format(fmt, args), Environment.NewLine));
            }
        }
Esempio n. 17
0
 public static void Log(string message, LogType type = LogType.Message)
 {
     ConsoleColor color = ConsoleColor.White;
     if (type == LogType.DebugVerbose)
         if (!DEBUG_VERBOSE) return;
         else type = LogType.Debug;
     switch (type)
     {
         case LogType.Message:
             color = ConsoleColor.White;
             break;
         case LogType.Warning:
             color = ConsoleColor.Yellow;
             break;
         case LogType.Error:
             color = ConsoleColor.Red;
             break;
         case LogType.Fatal:
             color = ConsoleColor.DarkRed;
             break;
         case LogType.Debug:
             color = ConsoleColor.Cyan;
             break;
     }
     Console.ForegroundColor = color;
     Console.Write("[" + type.ToString() + "] ");
     Console.ForegroundColor = ConsoleColor.Gray;
     Console.WriteLine(message);
 }
Esempio n. 18
0
File: Log.cs Progetto: freakaz/akio
        /// <summary>
        /// Write the message into log file.
        /// </summary>
        /// <param name="message">message.</param>
        /// <param name="type">message's type.</param>
        public void Write(string message, LogType type)
        {
            // check message
            if (message == null || message.Equals(""))
                throw new ArgumentNullException ("message");

            // open file and formate message
            StreamWriter writer = new StreamWriter (new FileStream (Name, FileMode.Append));
            DateTime time = DateTime.Now;
            string frmtMessage = time.ToString ("dd.MM.yy HH:mm:ss.fff") + "\t" + type.ToString () [0] + "\t" + message;

            // add message to list and write it into file
            Entries.Add (frmtMessage);

            // filter debug messages
            #if DEBUG
            Console.WriteLine (frmtMessage);
            writer.WriteLine (frmtMessage);
            #else
            if (type != LogType.Debug)
                writer.WriteLine (frmtMessage);
            #endif

            // clean up
            writer.Close ();
        }
Esempio n. 19
0
        public static void Write(string message, int rank, LogType logType)
        {
            if (rank <= 0) return;

            try
            {
                // first check the directory existence...
                if (!Directory.Exists(Path.GetDirectoryName(logFilePath)))
                    Directory.CreateDirectory(Path.GetDirectoryName(logFilePath));

                // check file existence...
                if (!File.Exists(logFilePath))
                    File.Create(logFilePath);

                    using (StreamWriter writer = new StreamWriter(logFilePath, true))
                    {
                        if (string.IsNullOrEmpty(message))
                            writer.WriteLine();
                        else
                            writer.WriteLine(string.Format("{0} | {1} | {2}", DateTime.Now.ToString("dd/MMM/yyyy hh:mm:ss"), logType.ToString(), message));
                    }

            }
            catch{}
        }
Esempio n. 20
0
 public static void LogError(string msg , LogType lt , Exception ex)
 {
     writeMutex.WaitOne();
     System.IO.StreamWriter file = new System.IO.StreamWriter(Env.ErrorFolderPath, true);
     file.WriteLine(lt.ToString() + ":");
     string[] lines = msg.Split('\n');
     foreach (var l in lines)
     {
         file.WriteLine(l);
     }
     file.WriteLine("_Time :"+ DateTime.Now.ToString(CultureInfo.InvariantCulture));
     if(ex != null)
     {
         var st = new StackTrace(ex, true);
         var stackFrames = st.GetFrames();
         if (stackFrames != null)
             foreach (var frame in stackFrames)
             {
                 file.WriteLine("_Frame : " + frame.ToString());
                 // Get the line number from the stack frame
                 var line = frame.GetFileLineNumber();
                 file.WriteLine("_Line : " + line.ToString());
             }
     }
     file.WriteLine("---------------------------------------------------------END----------------------------------------------------------");
     file.Close();
     writeMutex.ReleaseMutex();
 }
Esempio n. 21
0
        public void Log(string message, LogType logType, string userUsername)
        {
            GlobalContext.Properties["LogType"] = logType.ToString();
            GlobalContext.Properties["UserUsername"] = userUsername;

            log.Info(message);
        }
Esempio n. 22
0
    private void HandleLog(string log, string stack, LogType type)
    {
        Dictionary<string, string> dic = new Dictionary<string, string>();

        //dic.Add("log", log);
        //dic.Add("stack", stack);
        dic.Add("type", type.ToString());
        dic.Add("playTime", Time.realtimeSinceStartup.ToString());
        dic.Add("time", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"));

        dic.Add("ProcessorType", SystemInfo.processorType);
        dic.Add("ProcessorCount", SystemInfo.processorCount.ToString());

        dic.Add("Device-Uid", SystemInfo.deviceUniqueIdentifier);
        dic.Add("Device-Model", SystemInfo.deviceModel);
        dic.Add("Device-Name", SystemInfo.deviceName);
        dic.Add("OS", SystemInfo.operatingSystem);
        dic.Add("MemorySize", SystemInfo.systemMemorySize.ToString());

        dic.Add("GPU-Memory", SystemInfo.graphicsMemorySize.ToString());
        dic.Add("GPU-Name", SystemInfo.graphicsDeviceName);
        dic.Add("GPU-Vendor", SystemInfo.graphicsDeviceVendor);
        dic.Add("GPU-VendorID", SystemInfo.graphicsDeviceVendorID.ToString());
        dic.Add("GPU-id", SystemInfo.graphicsDeviceID.ToString());
        dic.Add("GPU-Version", SystemInfo.graphicsDeviceVersion);
        dic.Add("GPU-ShaderLevel", SystemInfo.graphicsShaderLevel.ToString());
        dic.Add("GPU-PixelFillrate", SystemInfo.graphicsPixelFillrate.ToString());

        //ravenClient.CaptureMessage(log, SharpRaven.Data.ErrorLevel.error, dic, null);

        ravenClient.CaptureUntiyLog(log, stack, type, dic, null);
    }
Esempio n. 23
0
        public void addLog(string method, string kind, string msg, LogType logType)
        {
            string localPath = "";
            string logPath = AppDomain.CurrentDomain.BaseDirectory + "log/" + logType.ToString() + "/";
            localPath = string.Format(logPath + "{0:yyyyMMdd}.log", DateTime.Now);
            lock (localPath)
            {
                StreamWriter writer = null;
                try
                {
                    System.IO.FileInfo info = new FileInfo(localPath);
                    if (!info.Directory.Exists)
                        info.Directory.Create();

                    writer = new StreamWriter(localPath, true, System.Text.Encoding.UTF8);
                    writer.WriteLine(string.Format("{0}[{1:HH:mm:ss}] 方法{2} 用户:{3}[end]", kind, DateTime.Now, method, msg));
                }
                catch
                {
                    if (writer != null)
                        writer.Close();
                }
                finally
                {
                    if (writer != null)
                        writer.Close();
                }
            }
        }
Esempio n. 24
0
        public static void Log(string data, LogType type, bool writeToConsole)
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\NJournals\\logs";
            DirectoryInfo di = new DirectoryInfo(path);
            if (!di.Exists) {
                di.Create();
            }

            if (writeToConsole) {
                Console.WriteLine(data);
            }

            using (StreamWriter sw = new StreamWriter(path + "\\NJournals" + DateTime.Now.ToString("MM-dd-yy") + ".log", true)) {

                sw.WriteLine("[" + type.ToString() + "] " + data);

                /*if (type != LogType.INFO &&
                    type != LogType.WARNING &&
                    type != LogType.ERR){
                    sw.WriteLine("[" + type.ToString() + "] " + data);
                } else {
                    sw.WriteLine(data);
                }*/
            }
        }
Esempio n. 25
0
 private void handleLog(string log, string stackTrace, LogType type)
 {
     _currentScrollPosition.y = Mathf.Infinity;
     if(_currentLog.Count == MAX_LOG)
         _currentLog.RemoveAt(0);
     _currentLog.Add (new LogMessage(type, string.Format ("[{0}] {1}\n{2}", type.ToString(), log, stackTrace)));
 }
Esempio n. 26
0
        public static void Write(LogType logType, string message)
        {
            // Pluralizing main directory name depending on LogType
            string logTypeDirectory =
                logType.ToString().EndsWith("s")
                ? logType + "es"
                : logType + "s";

            string filePath = RootDirectory+@"\"+logTypeDirectory+@"\";

            string fileExtension = "log";

            string fileName = logType+"_"+DateTime.Now.ToString("dd-MM-yyyy")+"."+fileExtension;

            // Format is [yyyy/MM/dd HH:mm:ss]
            string dateTime = "["+DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")+"] ";

            string dataToAppend = dateTime + NewLine + message + NewLine;

            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }

            File.AppendAllText(filePath+"\\"+ fileName, dataToAppend);
        }
Esempio n. 27
0
 public void WriteEntry(string text, LogType lt)
 {
     #if DEBUG
     Console.WriteLine(text);
     #endif
     sw.WriteLine(string.Format("{0}\t{1}\t{2}", DateTime.Now.ToString(), lt.ToString(), text));
     sw.Flush();
 }
Esempio n. 28
0
        public static void Print(LogType _type, object _obj)
        {
            Console.ForegroundColor = TypeColour[_type];

            Console.Write("[" + _type.ToString() + "] ");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(_obj.ToString());
        }
Esempio n. 29
0
        internal void logLine(LogType type, string msg, long time)
        {
#if DEBUG
            Debug.WriteLine("[" + type.ToString() + ", " + time + "]: " + msg);
#endif
            if(LogEvent != null && !m_ovpn.NoEvents)
                LogEvent(this, new LogEventArgs(type, msg, time));
        }
Esempio n. 30
0
        public bool write(LogType _logType,
                                    int        _handle,
                                    string        _actionName,
                                    string        _direction,
                                    string        _logMsg)
        {
            logFile = null;
            try
            {
#if  CONSOLE
                Console.WriteLine(DateTime.Now.ToString(gMsTimeFormat_) + "|" + _logType.ToString() +"|" +_actionName +"|"+_direction+ "|" + _logMsg);
#endif

                if (!Directory.Exists(path_))
                {
                    Directory.CreateDirectory(path_);
                }

                fileName = path_ + prefixName_ + "_" + DateTime.Now.ToString(gHourFormat_) + ".log";

                //string fileName = path_ + prefixName_ + "_" + DateTime.Now.ToString(gHourFormat_) + ".log";
                string logStr = string.Format(gLogStr_,
                                             DateTime.Now.ToString(gMsTimeFormat_),
                                                                  _logType,
                                                                   _handle,
                                                                  _actionName,
                                                                  _direction,
                                                                  _logMsg);
                
                if (File.Exists(fileName))
                {
                    logStr = "\r\n" + logStr + "\r\n" + gLogPostfixStr_;
                    logFile = File.Open(fileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
                    logFile.Seek(-8, SeekOrigin.End);
                }
                else
                {
                    logStr = gLogPrefixStr_ + "\r\n" + logStr + "\r\n" + gLogPostfixStr_;
                    logFile = File.Open(fileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
                }

                byte[] info = new UTF8Encoding(true).GetBytes(logStr);
                logFile.Write(info, 0, info.Length);
                logFile.Close();
                return true;
                
            }
            finally
            {
                if (logFile != null)
                {
                    logFile.Close();
                }
            }


        }
Esempio n. 31
0
 protected override void SendToLog(string source, LogType logType, string message)
 {
     if (!_called)
     {
         Console.WriteLine("{0} > {1} > {2} > {3}", "LogDate".PadRight(20, ' '), "LogCategory".PadRight(40, ' '),
                           "LogType".PadRight(10, ' '),
                           "LogMessage");
         _called = true;
     }
     Console.WriteLine("{0} > {1} > {2} > {3}", DateTime.Now.ToString().PadRight(20, ' '),
                       source.PadRight(40, ' '),
                       logType.ToString().PadRight(10, ' '),
                       message);
 }
Esempio n. 32
0
 internal void Log(string events, LogType logType, string className, int threadId)
 {
     using (UnitOfWork unitOfWork = new UnitOfWork())
     {
         unitOfWork.EventLogRepository.Add(new BitRexSql.Entity.EventLog()
         {
             Evento     = events,
             TipoEvento = logType.ToString(),
             Class      = className,
             ThreadId   = threadId
         });
         unitOfWork.Commit();
     }
 }
Esempio n. 33
0
    public void OnLogMessageReceived(string condition, string stackTrace, LogType type)
    {
        if (!_initialized)
        {
            return; // dsn not initialized or something exploded, don't try to send it
        }
        _lastErrorMessage = condition;
        if (type != LogType.Error && type != LogType.Exception && type != LogType.Assert)
        {
            if (AutoGenerateBreadcrumb) // add non-errors to the breadcrumb list
            {
                AddBreadcrumb(condition);
            }

            // only send errors, can be set somewhere what we send and what we don't
            return;
        }

        if (Time.time - _timeLastError <= MinTime)
        {
            return; // silently drop the event on the floor
        }
        _timeLastError = Time.time;
        if (type == LogType.Exception)
        {
            ScheduleException(condition, stackTrace);
        }
        else
        {
#if NET_4_6
            string message = $"{type.ToString()}: {condition}";
#else
            string message = type.ToString() + ": " + condition;
#endif
            ScheduleException(message, stackTrace);
        }
    }
Esempio n. 34
0
        static void Log(LogType type, string format, params object[] args)
        {
            var calleeName = new StackFrame(2, false).GetMethod().DeclaringType.Name;
            var lineNumber = new StackFrame(2, true).GetFileLineNumber();

            switch (type)
            {
            case LogType.Error:
                System.Diagnostics.Debug.WriteLine($"[{calleeName}:{lineNumber}] {type.ToString()} : {format}",
                                                   args);
                break;

            case LogType.Warn:
                System.Diagnostics.Debug.WriteLine($"[{calleeName}:{lineNumber}] {type.ToString()} : {format}",
                                                   args);
                break;

            case LogType.Log:
                System.Diagnostics.Debug.WriteLine($"[{calleeName}:{lineNumber}] {type.ToString()} : {format}",
                                                   args);
                break;

            case LogType.Info:
                System.Diagnostics.Debug.WriteLine($"[{calleeName}:{lineNumber}] {type.ToString()} : {format}",
                                                   args);
                break;

            case LogType.Trace:
                System.Diagnostics.Debug.WriteLine($"[{calleeName}:{lineNumber}] {type.ToString()} : {format}",
                                                   args);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
    private void Application_logMessageReceivedThreaded(string condition, string stackTrace, LogType type)
    {
        string txt = counter++ + " " + type.ToString() + ": " + condition;

        if (txt.Contains("Exception: NullReferenceException") && nullRefCounter < 50)
        {
            nullRefCounter++;
            return;
        }
        if (nullRefCounter >= 50)
        {
            nullRefCounter = 0;
        }
        Logs.Add(txt);
    }
Esempio n. 36
0
    //Capture debug.log output, send logs to Loggly
    public void HandleLog(string logString, string stackTrace, LogType type)
    {
        //Initialize WWWForm and store log level as a string
        level = type.ToString();
        var loggingForm = new WWWForm();

        //Add log message to WWWForm
        loggingForm.AddField("LEVEL", level);
        loggingForm.AddField("Message", logString);
        loggingForm.AddField("Stack_Trace", stackTrace);

        //Add any User, Game, or Device MetaData that would be useful to finding issues later
        loggingForm.AddField("Device_Model", SystemInfo.deviceModel);
        StartCoroutine(SendData(loggingForm));
    }
Esempio n. 37
0
        public static string GetLogMessage(string category, string source, LogType logType, string logMsg, string detail)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("****************** " + DateTime.Now + " ******************");
            sb.AppendLine("Category: " + category);
            sb.AppendLine("Source: " + source);
            sb.AppendLine("Type: " + logType.ToString());
            sb.AppendLine("Message: " + logMsg);
            sb.AppendLine("Detail:" + detail);
            sb.AppendLine(detail ?? "null");
            sb.AppendLine("*****************END*******************");
            sb.AppendLine();
            return(sb.ToString());
        }
Esempio n. 38
0
 void LogCallback(string condition, string stackTrace, LogType type)
 {
     if (type == LogType.Error || type == LogType.Exception)
     {
         if (!traces.Contains(stackTrace))
         {
             Dictionary <string, string> dic = new Dictionary <string, string>();
             dic.Add("Type", type.ToString());
             dic.Add("Condition", condition);
             dic.Add("StackTrace", stackTrace);
             LogEventInternal("Error", dic);
             traces.Add(stackTrace);
         }
     }
 }
Esempio n. 39
0
        private void LogCallbackHandler(string logString, string stackTrace, LogType type)
        {
            if (_sw == null)
            {
                return;
            }

            var log = string.Format("[{0}][{1}] {2}" + NEW_LINE + "{3}" + NEW_LINE,
                                    type.ToString(),
                                    System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),
                                    logString,
                                    stackTrace);

            _sw.Write(log);
        }
Esempio n. 40
0
        public static void Log(string line, LogType type)
        {
            if (!OutLogAvailable)
            {
                Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"logs\");
            }
            if (FullLog)
            {
                WriteDate(type);
                Console.WriteLine(line);
            }

            OutLog = OutLog + "[" + DateTime.Now.ToString("HH:mm") + "/" + type.ToString().ToUpper() + "]" + line + System.Environment.NewLine;
            File.WriteAllText(OutLogPath, OutLog);
        }
Esempio n. 41
0
        // == DECLARATIONS
        // ======================================================================

        // == CONST

        // == VAR

        // == CONSTRUCTOR(S)
        // ======================================================================

        // == METHOD(S)
        // ======================================================================

        /// <summary>
        /// Creates a log message.
        /// </summary>
        /// <param name="type">type of the log</param>
        /// <param name="message">message</param>
        /// <returns>String</returns>
        public static String createLog(Type origin, LogType type, String message)
        {
            String retValue = null;

            if (origin == null)
            {
                origin = typeof(LogUtil);
            }

            DateTime dateTime = DateTime.Now;

            retValue = $"{DateTimeUtil.getDateYYYYMMDD(DateTime.Now)} -> [{type.ToString()}] [{origin.Name}]: {message}".ToUpper();

            return(retValue);
        }
Esempio n. 42
0
        public static void AddWriteFileSave(LogType logType, string text)
        {
            string _regName = "ATAW_LOG_CONTENT_" + logType.ToString();
            var    _obj     = AtawAppContext.Current.PageFlyweight.PageItems[_regName];

            if (_obj != null)
            {
                AtawAppContext.Current.PageFlyweight.PageItems[_regName] = "{0}{1}{2}".AkFormat(_obj.ToString(), Environment.NewLine, text);
                //_obj = _obj.ToString() + text;
            }
            else
            {
                AtawAppContext.Current.PageFlyweight.PageItems[_regName] = text;
            }
        }
Esempio n. 43
0
        internal void AddLogMessage(string message, LogType logType)
        {
            var log
                = new Log
                {
                Date    = DateTime.Now,
                Message = message,
                LogType = logType.ToString()
                };

            foreach (ILogger observer in _observers)
            {
                observer.ProcessLogMessage <Log>(log);
            }
        }
Esempio n. 44
0
    private static void WriteLog(string logString, string stackTrace, LogType type)
    {
        string log = string.Format("[{0}][{1}] {2} \n {3} \n",
                                   type.ToString(),
                                   System.DateTime.Now.ToString("HH:mm:ss"),
                                   logString,
                                   stackTrace);

        if (LoggerNet.receiveThread != null)
        {
            LoggerNet.mutex.WaitOne();
            LoggerNet.log_list.Enqueue(log);
            LoggerNet.mutex.ReleaseMutex();
        }
    }
Esempio n. 45
0
        public static void AddLog(SpareEntities db, LogType logType, string operName, string msg)
        {
            var log = new TL_OPER()
            {
                OperName = operName,
                LogSite  = System.Net.Dns.GetHostName(),
                LogTime  = DateTime.Now,
                LogType  = logType.ToString(),
                Message  = msg,
            };

            db.TL_OPER.Add(log);

            LogHelper.Write(log.ToString());
        }
Esempio n. 46
0
        public virtual void Log(LogType type, Exception e, object message)
        {
            var sb = new StringBuilder();

            sb.AppendFormat(
                "{0}: {1}: {2}: {3}",
                Tracer.GetCurrentMethod(2),
                type.ToString(),
                e.GetType(),
                e.Message);
            sb.Append(message);
            sb.Append(e.ToString());

            this.Log(type: type, message: sb.ToString());
        }
        void QueueLog(string logString, string stackTrace, LogType type)
        {
            if (logs.Count > 1000)
            {
                while (logs.Count > 1000)
                {
                    logs.RemoveAt(0);
                }
            }

                #if CSHARP_7_3_OR_NEWER
            logString = $"{logString}\n{stackTrace}\n";
            logs.Add(new QueuedLog()
            {
                message = logString, logType = type.ToString(), timestamp = $"[{DateTime.Now.ToString("HH:mm:ss")}]"
            });
                #else
            logString = logString + "\n" + stackTrace + "\n";
            logs.Add(new QueuedLog()
            {
                message = logString, logType = type.ToString(), timestamp = "[" + DateTime.Now.ToString("HH:mm:ss") + "]"
            });
                #endif
        }
Esempio n. 48
0
 public static void WriteLine(string Text, LogType logType)
 {
     if (LogOutput != null)
     {
         LogOutputEventArgs args = new LogOutputEventArgs();
         args.Text    = Text;
         args.LogType = logType;
         //OnLogOuput(args);
         LogOutput?.Invoke(null, args);
     }
     else
     {
         System.Diagnostics.Debug.WriteLine(string.Format("<{0}> {1}", logType.ToString(), Text));
     }
 }
Esempio n. 49
0
        public override void Handle(LogType type, string message)
        {
            switch (type)
            {
            case LogType.Attack:
            case LogType.Magic:
            case LogType.Target:
            case LogType.Error:
            case LogType.Event:
                Console.WriteLine(type.ToString() + ": " + message);
                break;
            }

            this.PassToSuccessor(type, message);
        }
Esempio n. 50
0
        public void Display(Rect uiRect, GUIStyle style)
        {
            Color oriColor = GUI.color;

            GUI.color = GetColor();
            style.normal.textColor = GetColor();
            GUI.Label(uiRect, "[" + Type.ToString() + "] " + Text, style);
            GUI.color = oriColor;

            if (!_isDebugLogShowed)
            {
                CreateDebugLog();
                _isDebugLogShowed = true;
            }
        }
        void CaptureLog(string condition, string stacktrace, LogType type)
        {
            string log;

            if (type == LogType.Log)
            {
                log = condition;
            }
            else
            {
                log = String.Format("{2}: {0}\n{1}", condition, stacktrace, type.ToString().ToUpper());
            }

            Logs.Add(log);
        }
 public static void LogException(Exception ex, string classFullQualifiedName, LogType logType, string customMessage)
 {
     if (ex != null)
     {
         LogEntry log = new LogEntry();
         log.EventId   = 1;
         log.TimeStamp = DateTime.Now;
         log.Title     = ex.Message;
         log.Categories.Add(logType.ToString());
         log.Categories.Add(classFullQualifiedName);
         log.Message  = customMessage + "\r\n+Exception Message:\r\n" + ex.Message + "\r\n+Exception Stack Trace:\r\n" + ex.StackTrace;
         log.Severity = TraceEventType.Error;
         Logger.Write(log);
     }
 }
Esempio n. 53
0
        private static void OnLogHandler(string message, string stackTrace, LogType type)
        {
            if (useTimestamp)
            {
                streamWriter.Write(string.Format("{0:yyyy/MM/dd HH:mm:ss} - ", System.DateTime.Now));
            }

            streamWriter.WriteLine(type.ToString("F").PadRight(9) + ": " + message);
            if (type == LogType.Error || type == LogType.Exception || type == LogType.Assert)
            {
                streamWriter.Write(stackTrace);
                streamWriter.WriteLine("");
            }
            streamWriter.Flush();
        }
        private void AddLogMessage(string message, string stack)
        {
            NameValueCollection namevalue = new NameValueCollection();

            namevalue["Time"]            = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
            namevalue["Type"]            = LogType.ToString();
            namevalue["Condition"]       = message;
            namevalue["StackTrace"]      = stack;
            namevalue["OperatingSystem"] = SystemInfo.operatingSystem;
            namevalue["Device"]          = SystemInfo.deviceName;
            namevalue["DeviceIP"]        = GetLocalIp();
            namevalue["DeviceModel"]     = SystemInfo.deviceModel;

            mSendQueue.Enqueue(namevalue);
        }
Esempio n. 55
0
        public static void Log(LogType logType, string message, string trace = null)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Concat("Log Type : ", logType.ToString()));
            sb.AppendLine(string.Concat("Date: ", DateTime.Now.ToString()));
            if (trace != null)
            {
                sb.AppendLine(trace);
            }
            sb.AppendLine(message);
            sb.AppendLine(lineSeparator);
            File.AppendAllText(logPath, sb.ToString());
            sb.Clear();
        }
Esempio n. 56
0
        private void handleLog(string logString, string stackTrace, LogType logType)
        {
            // enqueue the message
            if (logType != LogType.Exception)
            {
                log.AppendFormat("{0}: {1}", logType.ToString(), logString);
            }
            else
            {
                // don't add log type to exceptions, as it's already in the string
                log.AppendLine(logString);
            }

            // enqueue the stack trace
            log.AppendLine(stackTrace);
        }
Esempio n. 57
0
        /// <summary>
        /// 保存日志对象实例
        /// </summary>
        protected virtual void SaveLog(object Message, LogType Type)
        {
            //if (Type <= this.ReadinLogLevel)
            //{
            //    return;
            //}
            DataHelper dh  = new DataHelper();
            ILog       log = this.entityfactory.CreateEntityInstance <ILog>();

            log.LOGCODE = (dh.GetMaxField(log, "LOGCODE", this.entityfactory) + 1);
            log.LOGTIME = DateTime.Now;
            log.CONTENT = Message.ToString();
            log.LOGTYPE = Type.ToString();
            IDvTable dvt = entityfactory.CreateDriveTable(log);
            int      i   = dvt.Insert();
        }
Esempio n. 58
0
        /// <summary>
        /// 获取单行信息
        /// </summary>
        /// <returns>生成单行信息</returns>
        public override string ToString()
        {
            StringBuilder strBuilder = new StringBuilder(128);

            strBuilder.Append(time.ToLongTimeString());
            strBuilder.Append("[-]");
            strBuilder.Append(userName);
            strBuilder.Append("[-]");
            strBuilder.Append(content);
            strBuilder.Append("[-]");
            strBuilder.Append(result);
            strBuilder.Append("[-]");
            strBuilder.Append(type.ToString());

            return(strBuilder.ToString());
        }
Esempio n. 59
0
        public override void WriteToLog(LogType logType, string message)
        {
            //Preparing the File name for the Log file
            string fileName = string.Format("{0}.txt", DateTime.Now.ToString("ddMMyyyyhh"));

            lock (lockObj)
            {
                //Creating the Streamwriter to write the log message in to the file
                using (StreamWriter streamWriter = new StreamWriter(filePath + fileName, true))
                {
                    streamWriter.WriteLine($"LogType : {logType.ToString()} \t  Time : {DateTime.Now.ToString("dd/MM/yyyy")}");
                    streamWriter.WriteLine($"Message : {message}");
                    streamWriter.Close();
                }
            }
        }
Esempio n. 60
0
    //Capture debug.log output, send logs to Loggly
    public void HandleLog(string logString, string stackTrace, LogType type)
    {
        var loggingForm = new WWWForm();
        // 'stackTrace' 변수는 기기 빌드에서는 비어 있으므로 직접 구한다.
        var trace = new StackTrace();

        loggingForm.AddField("localTimestamp",
                             DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff zzz", CultureInfo.InvariantCulture));
        loggingForm.AddField("stackTrace", trace.ToString());
        loggingForm.AddField("message", logString);
        loggingForm.AddField("deviceModel", SystemInfo.deviceModel);
        loggingForm.AddField("isEditor", Application.isEditor.ToString());
        loggingForm.AddField("logType", type.ToString());
        loggingForm.AddField("applicationVersion", Application.version);
        StartCoroutine(SendData(loggingForm));
    }