示例#1
0
 public LogEntry(DateTime logTime, string id, string message, LogEntryType type)
 {
     LogTime = logTime;
     Id      = id;
     Message = message;
     Type    = type;
 }
 void IActivityMonitorBoundClient.SetMonitor(IActivityMonitorImpl?source, bool forceBuggyRemove)
 {
     if (source != null && _source != null)
     {
         throw ActivityMonitorClient.CreateMultipleRegisterOnBoundClientException(this);
     }
     // Silently ignore null => null or monitor => same monitor.
     if (source != _source)
     {
         _prevLogType = LogEntryType.None;
         _prevlogTime = DateTimeStamp.Unknown;
         Debug.Assert((source == null) != (_source == null));
         if ((_source = source) == null)
         {
             if (_file != null)
             {
                 _file.Close();
             }
             _file = null;
         }
         else
         {
             // If initialization failed, we let the file null: this monitor will not
             // work (the error will appear in the Critical errors) but this avoids
             // an exception to be thrown here.
             var f = new MonitorBinaryFileOutput(_path, _source.UniqueId, _maxCountPerFile, _useGzipCompression);
             if (f.Initialize(_source.InternalMonitor))
             {
                 var g = _source.CurrentGroup;
                 _currentGroupDepth = g != null ? g.Depth : 0;
                 _file = f;
             }
         }
     }
 }
 public ActivityLogEntry(string Message)
 {
     m_Timestamp = DateTime.Now;
     m_Type = LogEntryType.Message;
     m_Msg = Message;
     m_Ref = null;
 }
 public ActivityLogEntry(string Message, long msTime)
 {
     m_Timestamp = DateTime.Now;
     m_Type = LogEntryType.Timing;
     m_Msg = Message;
     m_Ref = msTime;
 }
 public ActivityLogEntry(LogEntryType typeEntry, string Message, object Reference)
 {
     m_Timestamp = DateTime.Now;
     m_Type = typeEntry;
     m_Msg = Message;
     m_Ref = Reference;
 }
示例#6
0
        public void WriteToLog(LogEntryType logEntryType, Integration integration, DataSource dataSource, JobInstance jobInstance, JobStepInstance jobStepInstance, string message)
        {
            using (var dbContext = new ls.LoggingDataContext(ConnectionString))
            {
                Guid?integrationId     = null;
                Guid?dataSourceId      = null;
                Guid?jobInstanceId     = null;
                Guid?jobStepInstanceId = null;

                if (integration != null)
                {
                    integrationId = integration.Id;
                }

                if (dataSource != null)
                {
                    dataSourceId = dataSource.Id;
                }

                if (jobInstance != null)
                {
                    jobInstanceId = jobInstance.Id;
                }

                if (jobStepInstance != null)
                {
                    jobStepInstanceId = jobStepInstance.Id;
                }

                dbContext.AddLogEntry(integrationId, dataSourceId, jobInstanceId, jobStepInstanceId, (byte)logEntryType, message);
            }
        }
示例#7
0
        public void WriteLine(LogEntryType logEntryType, String message)
        {
            /* Timestamps are represented in the Round Trip Format Specifier
             (http://msdn.microsoft.com/en-us/library/az4se3k1.aspx#Roundtrip). */
              var timestamp = DateTime.Now.ToUniversalTime().ToString("o");

              String type;
              switch (logEntryType)
              {
            case LogEntryType.Info:
              type = "INF";
              break;
            case LogEntryType.Warning:
              type = "WRN";
              break;
            case LogEntryType.Error:
              type = "ERR";
              break;
            default:
              type = "UNK";
              break;
              }

              this._writer.WriteLine(String.Format("{0} - {1} - {2}", timestamp, type, message));
        }
示例#8
0
        /// <summary>
        /// по одному magic сообщения отправляются не чаще чем в minMillsBetween
        /// </summary>
        public void LogMessageFormatCheckFlood(LogEntryType entryType, int msgMagic,
                                               string fmt, params object[] ptrs)
        {
            DateTime time;

            if (!logFloodTimes.TryGetValue(msgMagic, out time))
            {
                logFloodTimes.Add(msgMagic, DateTime.Now.AddMilliseconds(minMillsBetween));
            }
            else
            {
                if (DateTime.Now < time)
                {
                    return;
                }
                try
                {
                    logFloodTimes[msgMagic] = DateTime.Now.AddMilliseconds(minMillsBetween);
                }
                catch
                {
                }
            }
            Logger.Log(entryType, fmt, ptrs);
        }
示例#9
0
        public void WriteLine(LogEntryType logEntryType, String message)
        {
            /* Timestamps are represented in the Round Trip Format Specifier
             * (http://msdn.microsoft.com/en-us/library/az4se3k1.aspx#Roundtrip). */
            var timestamp = DateTime.Now.ToUniversalTime().ToString("o");

            String type;

            switch (logEntryType)
            {
            case LogEntryType.Info:
                type = "INF";
                break;

            case LogEntryType.Warning:
                type = "WRN";
                break;

            case LogEntryType.Error:
                type = "ERR";
                break;

            default:
                type = "UNK";
                break;
            }

            this._writer.WriteLine(String.Format("{0} - {1} - {2}", timestamp, type, message));
        }
示例#10
0
        public static void WriteToLog(LogEntryType logEntryType, Integration integration, DataSource dataSource, JobInstance jobInstance, JobStepInstance jobStepInstance, Func <string> messageDelegate)
        {
            if (integration == null && jobInstance != null)
            {
                integration = jobInstance.Integration;
            }

            if (jobStepInstance == null && jobInstance != null)
            {
                jobStepInstance = jobInstance.RunningJobStepInstance;
            }

            string message = null;

            foreach (var logger in registeredLoggers)
            {
                if ((int)logEntryType <= (int)logger.MaxLoggingLevel)
                {
                    if (message == null)
                    {
                        message = messageDelegate();
                    }

                    logger.Logger.WriteToLog(logEntryType, integration, dataSource, jobInstance, jobStepInstance, message);
                }
            }
        }
示例#11
0
 public static void Log(LogEntryType type, LogActionType action, string log, string metadata)
 {
     WriteLog($"LogEntryType: {type}\n" +
              $"LogActionType : {action}\n" +
              $"Log : {log}\n" +
              $"Metadata : {metadata}");
 }
示例#12
0
 public LogEntry(DateTime logTime, string entryId, string message, LogEntryType type)
 {
     LogTime = logTime;
     EntryId = entryId;
     Message = message;
     Type = type;
 }
 public LogEntry(String line)
 {
     Raw         = line;
     Date        = ParseDate();
     Type        = ParseType();
     Description = ParseDescription();
 }
示例#14
0
        public void LogMessageCheckFlood(LogEntryType entryType, int msgMagic, int minMills,
                                         string str)
        {
            DateTime time;

            if (!logFloodTimes.TryGetValue(msgMagic, out time))
            {
                logFloodTimes.Add(msgMagic, DateTime.Now.AddMilliseconds(minMills));
            }
            else
            {
                if (DateTime.Now < time)
                {
                    return;
                }
                try
                {
                    logFloodTimes[msgMagic] = DateTime.Now.AddMilliseconds(minMills);
                }
                catch
                {
                }
            }
            Logger.Log(entryType, str);
        }
示例#15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogEntry"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="messageTemplate">The message template.</param>
 /// <param name="exception">The exception.</param>
 /// <param name="args">The arguments.</param>
 public LogEntry(LogEntryType type, string messageTemplate, Exception exception, params object[] args)
 {
     Type            = type;
     MessageTemplate = messageTemplate;
     Exception       = exception;
     Arguments       = args;
 }
示例#16
0
 public static void AddLogEntry(LogEntryType logEntryType, string messageType, string contents = null, string message = null)
 {
     if (MessageLog != null)
     {
         MessageLog.AddLogEntry(new MessageLogEntry(logEntryType, messageType, contents, message, new StackTrace(true)));
     }
 }
示例#17
0
 private void Output(LogEntryType type, [NotNull] string message)
 {
     foreach (var line in _TextLogFormatter.Format(type, message))
     {
         System.Diagnostics.Debug.WriteLine(line);
     }
 }
示例#18
0
 internal LogEntry(LogEntryType type, string message, string details)
 {
     this.type      = type;
     this.message   = message;
     this.details   = details;
     this.timestamp = DateTime.Now;
 }
示例#19
0
 void IActivityMonitorBoundClient.SetMonitor( IActivityMonitorImpl source, bool forceBuggyRemove )
 {
     if( source != null && _source != null ) throw ActivityMonitorClient.CreateMultipleRegisterOnBoundClientException( this );
     // Silently ignore null => null or monitor => same monitor.
     if( source != _source )
     {
         _prevLogType = LogEntryType.None;
         _prevlogTime = DateTimeStamp.Unknown;
         Debug.Assert( (source == null) != (_source == null) );
         if( (_source = source) == null )
         {
             if( _file != null ) _file.Close();
             _file = null;
         }
         else
         {
             // If initialization failed, we let the file null: this monitor will not
             // work (the error will appear in the Critical errors) but this avoids
             // an exception to be thrown here.
             var f = new MonitorBinaryFileOutput( _path, ((IUniqueId)_source).UniqueId, _maxCountPerFile, _useGzipCompression );
             if( f.Initialize( new SystemActivityMonitor( false, null ) ) )
             {
                 var g = _source.CurrentGroup;
                 _currentGroupDepth = g != null ? g.Depth : 0;
                 _file = f;
             }
         }
     }
 }
示例#20
0
        private static int LogMessageToTextFile(LogEntryType type, string message)
        {
            try
            {

                string logmsg = "----------------------------\r\n" + //separator for new log
                    "Local time: " + DateTime.Now.ToString() + "\r\n" + //local time
                    //summary info                
                    "Application Name: " + applicationName + "\r\n" +
                    "Log Type: " + type.ToString() + "\r\n" +
                    "Error Message:\r\n" + message + "\r\n";
                
                //allow error log to be encoded by local time
                string logFileName = string.Format(errorLogFileName, DateTime.Now);
                using (StreamWriter w = File.AppendText(logFileName))
                {
                    w.Write(logmsg);
                }

                return 0; //logged to local file
            }
            catch (Exception e)
            {
                //ignore errors, avoid infinite loop of trying to log errors
#if DEBUG
                System.Console.WriteLine(e.ToString());
                System.Diagnostics.Debug.WriteLine(e.ToString());
#endif

                return -1;
            }
        }
示例#21
0
 internal LogEntry(LogEntryType type, string text, DateTime time, string logName)
 {
     Type    = type;
     Text    = text;
     Time    = time;
     LogName = logName;
 }
示例#22
0
 public void LogEntry(LogEntryType log, int level, string str)
 {
     if (IsDebugging() || Global.developer >= level)
     {
         Debug.Log(string.Format("<color=white>{0}</color>[<color={3}>{1}</color>] {2}", log.ToString().PadRight(10), ToString(), str, GetLogColor()), base.gameObject);
     }
 }
 /// <summary>
 /// Opens this writer if it is not already opened.
 /// </summary>
 /// <returns>True on success, false otherwise.</returns>
 public bool Open()
 {
     if (_source == null)
     {
         throw new InvalidOperationException("CKMonWriterClient must be registered in an ActivityMonitor.");
     }
     using (_source.ReentrancyAndConcurrencyLock())
     {
         if (_file != null)
         {
             return(true);
         }
         _file        = new MonitorBinaryFileOutput(_path, _source.UniqueId, _maxCountPerFile, _useGzipCompression);
         _prevLogType = LogEntryType.None;
         _prevlogTime = DateTimeStamp.Unknown;
         if (_file.Initialize(_source.InternalMonitor))
         {
             var g = _source.CurrentGroup;
             _currentGroupDepth = g != null ? g.Depth : 0;
         }
         else
         {
             _file = null;
         }
     }
     return(_file != null);
 }
示例#24
0
 protected TradeParser(LogEntryType type, Regex regMatch, List <Regex> regsClean)
 {
     _type            = type;
     _regMatch        = regMatch;
     _regsClean       = regsClean;
     _currencyService = new CurrencyService();
 }
示例#25
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="type">Type of the log entry.</param>
        /// <param name="message">Message of the log entry.</param>
        public LogEntry(LogEntryType type, string message)
        {
            this.type    = type;
            this.message = message;

            timeStamp = DateTime.Now;
        }
示例#26
0
        private static string GetLogLine(DateTime logDate, LogEntryType logEntryType, JobInstance jobInstance, JobStepInstance jobStepInstance, JobBatch jobBatch, string message)
        {
            StringBuilder fullLine = new StringBuilder();

            fullLine.Append(logDate);
            fullLine.Append("\t");
            fullLine.Append(logEntryType);
            fullLine.Append("\t");
            fullLine.Append(string.Format("{0} ({1})", jobInstance.Integration.Name, jobInstance.Integration.Id));
            fullLine.Append("\t");
            fullLine.Append(string.Format("{0} ({1})", jobBatch.AssociatedDataSource.DataSource.Name, jobBatch.AssociatedDataSource.DataSource.Id));
            fullLine.Append("\t");
            fullLine.Append(string.Format("{0} ({1})", jobInstance.Job.Name, jobInstance.Job.Id));
            fullLine.Append("\t");
            fullLine.Append(string.Format("{0} ({1})", jobInstance.QueueRequest.InvocationSourceType, jobInstance.QueueRequest.Id));
            fullLine.Append("\t");
            fullLine.Append(jobInstance.Id);
            fullLine.Append("\t");
            fullLine.Append(JobFilterHelper.GetTextForDatabase(jobInstance.Filters));
            fullLine.Append("\t");
            fullLine.Append(string.Format("{0} ({1})", jobStepInstance.JobStep.Name, jobStepInstance.JobStep.Id));
            fullLine.Append("\t");
            fullLine.Append(jobStepInstance.Id);
            fullLine.Append("\t");
            fullLine.Append(message);

            return(fullLine.ToString());
        }
示例#27
0
 /// <summary>
 /// Called when [write to external log].
 /// </summary>
 /// <param name="formattedMessage">The formatted message.</param>
 /// <param name="type">The type.</param>
 /// <param name="extra">The extra.</param>
 protected void OnWriteToExternalLog(string formattedMessage, LogEntryType type, object extra)
 {
     if (this.WriteToExternalLog != null)
     {
         this.WriteToExternalLog(formattedMessage, type, extra);
     }
 }
示例#28
0
 /// <summary>
 /// Called when [log format message].
 /// </summary>
 /// <param name="logType">Type of the log.</param>
 /// <param name="dateTime">The date time.</param>
 /// <param name="moduleName">Name of the module.</param>
 /// <param name="procedureName">Name of the procedure.</param>
 /// <param name="message">The message.</param>
 private void OnLogFormatMessage(LogEntryType logType, string dateTime, string moduleName, string procedureName, string message)
 {
     if (this.LogFormatMessage != null)
     {
         this.LogFormatMessage(logType, dateTime, moduleName, procedureName, message);
     }
 }
示例#29
0
        public override void AddEntry(string message, LogEntryType type)
        {
#if DEBUG
            log.Debug($"Current memory usage: {System.Diagnostics.Process.GetCurrentProcess().WorkingSet64/1000000} Mb");
#endif

            switch (type)
            {
            case LogEntryType.Debug:
                log.Debug(message);
                return;

            case LogEntryType.Error:
                log.Error(message);
                return;

            case LogEntryType.Information:
                log.Info(message);
                return;

            case LogEntryType.Warning:
                log.Warn(message);
                return;
            }
        }
示例#30
0
文件: AppLog.cs 项目: Klocman/MSREG
 public static IEnumerable<LogEntry> GetLogEntries(LogEntryType filterLevel)
 {
     lock (LogEntryList)
     {
         return LogEntryList.Where(x => x.Type.CompareTo(filterLevel) >= 0).ToArray();
     }
 }
示例#31
0
 public void Log(string message, LogEntryType type = LogEntryType.Information)
 {
     if (!_logEntryTypes.ContainsKey(type))
     {
         return;
     }
     try
     {
         if (!EventLog.SourceExists("OptimaJet.WorkflowServer"))
         {
             EventLog.CreateEventSource("OptimaJet.WorkflowServer", "OptimaJet.WorkflowServer");
         }
         eventLog1.Source = "OptimaJet.WorkflowServer";
         if (type == LogEntryType.Information)
         {
             eventLog1.WriteEntry(message, EventLogEntryType.Information);
         }
         else
         {
             eventLog1.WriteEntry(message, EventLogEntryType.Error);
         }
     }
     catch
     {
         // ignored
     }
 }
示例#32
0
 public AnalyticsLogEntry(Guid userGuid, LogEntryType logEntryType, string data, float eventTime)
 {
     UserGuid     = userGuid;
     LogEntryType = logEntryType;
     Data         = data;
     EventTime    = eventTime;
 }
示例#33
0
        public static void Log(string message, LogEntryType type)
        {
            if (_eventLog == null)
            {
                InitEventLog();
            }

            if ((int)type > LogLevel)
            {
                return;
            }

            string            entryTypeText = "";
            EventLogEntryType callType      = EventLogEntryType.Information;

            if (type == LogEntryType.Error)
            {
                entryTypeText = "Error";
                callType      = EventLogEntryType.Error;
            }
            else if (type == LogEntryType.Information)
            {
                entryTypeText = "Information";
                callType      = EventLogEntryType.Information;
            }
            else if (type == LogEntryType.Warning)
            {
                entryTypeText = "Warning";
                callType      = EventLogEntryType.Warning;
            }

            Console.WriteLine(String.Format("{0}: {1}", entryTypeText, message));
            _eventLog.WriteEntry(message, callType);
        }
示例#34
0
            public ILogger Log(string value, LogEntryType type)
            {
                value = XmlUtility.Sanitize(value);
                var xmlLogEntry = new XElement("entry",
                                               new XAttribute("time", DateTime.UtcNow),
                                               new XAttribute("id", Guid.NewGuid()),
                                               new XAttribute("type", (int)type),
                                               new XElement("message", value));

                lock (LogLock)
                {
                    var document       = _parent.GetDocument();
                    var parentLogEntry = document.Root
                                         .Elements()
                                         .Where(s => s.Attribute("id").Value == _element.Attribute("id").Value)
                                         .First();
                    parentLogEntry.Add(xmlLogEntry);
                    // adjust log level of the parent log entry
                    var parentLogEntryType = (LogEntryType)Enum.Parse(typeof(LogEntryType), parentLogEntry.Attribute("type").Value);
                    if (type > parentLogEntryType)
                    {
                        parentLogEntry.Attribute("type").SetValue((int)type);
                    }
                    document.Save(_parent._path);
                }

                // Support a depthness of 2 for now.
                return(this);
            }
示例#35
0
 public LogEntry(DateTime logTime, string id, string message, LogEntryType type)
 {
     LogTime = logTime;
     Id = id;
     Message = message;
     Type = type;
 }
示例#36
0
 public WriteAnonymousLogData(Guid userGuid, float gameTime, LogEntryType entryType, string data)
 {
     _userGuid = userGuid;
     _gameTime = gameTime;
     _type     = entryType;
     _data     = data;
 }
示例#37
0
文件: Log.cs 项目: rubenv/tripod
 internal LogEntry (LogEntryType type, string message, string details)
 {
     this.type = type;
     this.message = message;
     this.details = details;
     this.timestamp = DateTime.Now;
 }
示例#38
0
 public LogEntry(LogEntryType entryType, DateTime dateTimeUtc, string text, string details)
 {
     EntryType   = entryType;
     DateTimeUtc = dateTimeUtc;
     Text        = text;
     Details     = details;
 }
示例#39
0
        private static void LoadConfig(string configFileName)
        {
            var xmlReader = new XmlTextReader(_appInstallPath + @"\" + configFileName);

            while (xmlReader.Read())
            {
                if ((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == "add"))
                {
                    string key = xmlReader.GetAttribute("key");
                    string val = xmlReader.GetAttribute("value");

                    switch (key)
                    {
                    case "logfilename":
                        _logFileName = val;
                        break;

                    case "loglevel":
                        try
                        {
                            _logLevel = (LogEntryType)Int32.Parse(val);
                        }
                        catch (Exception)
                        {
                            _logLevel = LogEntryType.Error;
                        }
                        break;
                    }
                }
            }

            _log = new Logger(_logFileName, _logLevel);
        }
        private ConsoleColor ConvertConsoleColour(LogEntryType type)
        {
            switch (type)
            {
            case LogEntryType.Verbose:
                return(ConsoleColor.DarkGray);

            case LogEntryType.Info:
                return(ConsoleColor.Gray);

            case LogEntryType.Success:
                return(ConsoleColor.Green);

            case LogEntryType.Error:
                return(ConsoleColor.Red);

            case LogEntryType.Comment:
                return(ConsoleColor.DarkGreen);

            case LogEntryType.Warning:
                return(ConsoleColor.Yellow);

            default: return(ConsoleColor.Gray);
            }
        }
示例#41
0
文件: LogEntry.cs 项目: kami-/Prizet
 /// <summary>
 /// Initializes a new instance of LogEntry with username, message and log entry type.
 /// </summary>
 /// <param name="userName">Username who generated the log entry.</param>
 /// <param name="message">Message associated with the log entry.</param>
 /// <param name="entryType">Type of log entry.</param>
 public LogEntry(string userName, string message, LogEntryType entryType)
 {
     this._TimwGenerated = DateTime.Now;
     this._UserName = userName;
     this._Message = message;
     this._EntryType = entryType;
 }
示例#42
0
        /// <summary>
        /// Convert a LogEntryType to the corresponding log4net level.
        /// </summary>
        /// <param name="entryType">An entry type.</param>
        /// <returns>the corresponding log4net level</returns>
        private static Level FromLogEntryType(LogEntryType entryType)
        {
            Level result;

            switch (entryType)
            {
            case LogEntryType.Debug:
                result = log4net.Core.Level.Debug;
                break;

            case LogEntryType.Information:
                result = log4net.Core.Level.Info;
                break;

            case LogEntryType.Warning:
                result = log4net.Core.Level.Warn;
                break;

            default:
                result = log4net.Core.Level.Error;
                break;
            }

            return(result);
        }
示例#43
0
 public LEMCCloseGroup( Guid monitorId, int depth, DateTimeStamp previousLogTime, LogEntryType previousEntryType, DateTimeStamp t, LogLevel level, IReadOnlyList<ActivityLogGroupConclusion> c )
     : base( t, level, c )
 {
     _monitorId = monitorId;
     _depth = depth;
     _previousEntryType = previousEntryType;
     _previousLogTime = previousLogTime;
 }
示例#44
0
 public LEMCLog( Guid monitorId, int depth, DateTimeStamp previousLogTime, LogEntryType previousEntryType, string text, DateTimeStamp t, string fileName, int lineNumber, LogLevel l, CKTrait tags, CKExceptionData ex )
     : base( text, t, fileName, lineNumber, l, tags, ex )
 {
     _monitorId = monitorId;
     _depth = depth;
     _previousEntryType = previousEntryType;
     _previousLogTime = previousLogTime;
 }
示例#45
0
 public void Custom(LogEntryType type, string message, Exception exception = null)
 {
     lock (writeLock)
     {
         writer.WriteLine("{0}: {1}", type.ToString().ToUpper(), message);
         WriteException(exception);
     }
 }
示例#46
0
 public LogEntry(TimeSpan loggedTotalWorldTime, ILoggable loggable, LogEntryType entryType, TimeSpan logEntryLifetime)
 {
     _loggedTotalWorldTime = loggedTotalWorldTime;
     _entryType = entryType;
     _title = loggable.Title;
     _details = loggable.Details.ToArray();
     _fadeHelper = new TimedLerpHelper(loggedTotalWorldTime + logEntryLifetime - Constants.LogRenderer.FadeDuration, Constants.LogRenderer.FadeDuration, 1f, 0f);
 }
示例#47
0
 /// <summary>
 /// Initializes a new instance of a log entry
 /// </summary>
 /// <param name="id">The unique id for this entry</param>
 /// <param name="type">The log entry type</param>
 /// <param name="message">The message to be logged</param>
 /// <param name="logTime">The log time.</param>
 /// <param name="exception">The exception information to be logged</param>
 public LogEntry(int id, LogEntryType type, string message, DateTime logTime, Exception exception = null)
 {
     Id = id;
     Type = type;
     Message = message;
     Exception = exception != null ? new ExceptionEntry(exception) : null;
     LogTime = logTime;
 }
示例#48
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="type">Log entry type.</param>
        /// <param name="id">Log entry ID.</param>
        /// <param name="size">Specified how much data was readed or written.</param>
        /// <param name="text">Description text.</param>
        public LogEntry(LogEntryType type, string id, long size, string text)
        {
            m_Type = type;
            m_ID = id;
            m_Size = size;
            m_Text = text;

            m_Time = DateTime.Now;
        }
示例#49
0
 /// <summary>
 /// Initializes a new instance of this type.
 /// </summary>
 /// <param name="entryType">The type of the log-entry.</param>
 /// <param name="eventId">A unique ID for this event.</param>
 /// <param name="message">The complete message which was logged.</param>
 /// <param name="sourceFile">The file from which the log was triggered.</param>
 /// <param name="sourceLineNumber">The line-number inside the <paramref name="sourceFile"/> from which the log was triggered.</param>
 /// <param name="sourceMethodName">The method-name inside the <paramref name="sourceFile"/> from which the log was triggered.</param>
 public LoggerEventArgs(LogEntryType entryType, string eventId, string message, string sourceFile, int sourceLineNumber, string sourceMethodName)
 {
     EntryType = entryType;
     Message = message;
     SourceFile = sourceFile;
     SourceLineNumber = sourceLineNumber;
     SourceMethodName = sourceMethodName;
     EventId = eventId;
 }
示例#50
0
文件: Logger.cs 项目: xorkrus/vk_wm
        public Logger(string logFileName, LogEntryType maxErrorLevel)
        {
            _logFileName = logFileName;
            _maxErrorLevel = maxErrorLevel;

            var sw = new StreamWriter(_logFileName, false);
            sw.WriteLine("Application log started at " + DateTime.Now.ToString("dd/MM/YYYY HH:mm:ss\r\n"));
            sw.Flush();
            sw.Close();
        }
示例#51
0
        public void Log(string value, LogEntryType type)
        {
            XDocument document = GetDocument();

            document.Root.Add(new XElement("entry",
                                  new XAttribute("time", DateTime.Now),
                                  new XAttribute("type", (int)type),
                                  value));

            document.Save(_path);
        }
示例#52
0
        public ILogger Log(string value, LogEntryType type)
        {
            IDeploymentStatusFile statusFile = _status.Open(_id);
            if (statusFile != null)
            {
                statusFile.UpdateProgress(value);
            }

            // No need to wrap this as we only support top-level progress
            return _innerLogger.Log(value, type);
        }
示例#53
0
 public static void Log(LogEntryType type, LogActionType action, string log, string metadata)
 {
     if (WriteInConsole)
         ConsoleLogger.Log(type, action, log, metadata);
     if (WriteInDiagnostics)
         DiagnosticLogger.Log(type, action, log, metadata);
     if (WriteInDb)
         DbLog.Log(type, action, log, metadata);
     if (WriteInFile)
         FileLogger.Log(type, action, log, metadata, LogFilePath);
 }
        private void SetStatus(string message, LogEntryType logType)
        {
            string textDate = DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss.fff");
            if (dgvLog.Rows.Count > 500) dgvLog.Rows.Clear();

            int rowIndex = dgvLog.Rows.Add();
            DataGridViewRow row = dgvLog.Rows[rowIndex];
            row.Cells[0].Value = rowIndex + 1;
            row.Cells[1].Value = textDate;
            row.Cells[2].Value = message;
            dgvLog.FirstDisplayedScrollingRowIndex = rowIndex;
        }
示例#55
0
文件: LogEntry.cs 项目: ru-sh/dnxt
 public LogEntry(DateTime utc, string message, LogEntryType type, Guid logId, object info, IEnumerable<string> categories, string filePath, int line, string memberName)
 {
     Utc = utc;
     Msg = message;
     Type = type;
     LogId = logId;
     Info = info;
     Categories = categories;
     Line = line;
     FileName = filePath == null ? "" : Path.GetFileName(filePath);
     MemberName = memberName;
 }
示例#56
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="type">Log entry type.</param>
 /// <param name="id">Log entry ID.</param>
 /// <param name="userIdentity">Log entry owner user or null if none.</param>
 /// <param name="size">Log entry read/write size in bytes.</param>
 /// <param name="text">Log text.</param>
 /// <param name="localEP">Local IP end point.</param>
 /// <param name="remoteEP">Remote IP end point.</param>
 /// <param name="exception">Exception happened. Can be null.</param>
 public LogEntry(LogEntryType type,string id,GenericIdentity userIdentity,long size,string text,IPEndPoint localEP,IPEndPoint remoteEP,Exception exception)
 {   
     m_Type          = type;
     m_ID            = id;
     m_pUserIdentity = userIdentity;
     m_Size          = size;
     m_Text          = text;
     m_pLocalEP      = localEP;
     m_pRemoteEP     = remoteEP;
     m_pException    = exception;
                 
     m_Time = DateTime.Now;
 }
示例#57
0
        public void Add(string text, LogEntryType type)
        {
            entries.Add(new Tuple<string, LogEntryType>(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + ": " + text, type));

            // This is the stupidest method of redrawing the form, but it has to be threadsafe
            this.Invoke(new UpdateDelegate(delegate(){
                PerformLayout();
                Invalidate();
                Update();
                Refresh();
                Application.DoEvents();
            }));
        }
示例#58
0
文件: Logger.cs 项目: xorkrus/vk_wm
        public void Write(LogEntryType entryType, string message)
        {
            if (entryType > _maxErrorLevel) return;

            //FIXME! если в один лог будут писать и приложение, и служба нотификаций,
            // возможна ситуация, когда файл занят и вылетит исключение.
            // (это не проблема, если лог будет отключён в продакшене)
            var sw = new StreamWriter(_logFileName, true);
            sw.Write(DateTime.Now.ToString("HH:mm:ss"));
            sw.WriteLine(" - " + message);
            sw.Flush();
            sw.Close();
        }
示例#59
0
        public void Log(LogEntryType logType,
            string preffix, int counter, string message, params object[] ptrs)
        {
            int countLeft;
            if (countByCat.TryGetValue(preffix, out countLeft))
            {
                if (countLeft <= 0) return;
                countByCat[preffix] = countByCat[preffix] - 1;
            }
            else
                countByCat.Add(preffix, counter);

            Logger.Log(logType, message, ptrs);
        }
示例#60
0
 public LogEntry(
       string user
     , string source
     , string message
     , LogEntryType type
     , DateTime date)
 {
     this.Id = 0;
     this.User = user;
     this.Source = source;
     this.Message = message;
     this.Type = type;
     this.Date = date;
 }