/// <summary> /// private Constructor for deserialization /// </summary> /// <param name="type"></param> /// <param name="message"></param> /// <param name="time"></param> private Log9KEntry(LogEntryTypes type, string message, Log9KTime time) { Message = message; Type = type; Time = time; TypeString = type.ToString(); }
public static void AddLogEntry( LogEntryTypes type, string username, string entrytext, string con ) { SqlHelper.ExecuteDataset( con, "spAddLogEntry", TextualRepresentation.GetDescription( type ), entrytext, username ); }
public static void AddLogEntry( LogEntryTypes type, string username, string entrytext ) { SqlHelper.ExecuteDataset( System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"], "spAddLogEntry", TextualRepresentation.GetDescription( type ), entrytext, username ); }
public SimpleLogEntry( string info, Directions direction, LogEntryTypes logType) { _info = info; _logType = logType; _direction = direction; _createdAt = DateTime.UtcNow; }
/// <summary> /// <para>Primary log method, log message with given type</para> /// <remarks>Not for custom type entries!!!</remarks> /// </summary> /// <param name="type"></param> /// <param name="message"></param> /// <param name="level"></param> public bool Log(LogEntryTypes type, string message, Levels level = Levels.PRIMARY) { if (string.IsNullOrEmpty(message)) { InnerLog("Ошибка: в методе Log() строка message пуста либо равна null!"); return(false); } Log9KEntry logEntry = new Log9KEntry(type, message, level); return(Log(logEntry)); }
/// <summary> /// /// <remark> /// <para>Do not create entry with type CUSTOM using this constructor, ArgumentException will be raised</para> /// <para>Use constructor for custom type instead</para> /// </remark> /// </summary> /// <param name="type"></param> /// <param name="message"></param> /// <param name="level"></param> public Log9KEntry(LogEntryTypes type, string message, Levels level = Levels.PRIMARY) { if (type == LogEntryTypes.CUSTOM) { throw new ArgumentException( "Данный конструктор не предназначен для создания пользовательских логов" ); } Message = message; Type = type; TypeString = type.ToString(); Time = GetCurrentLog9KTime(); Level = level; if (!IsInnerLog()) { Counter++; ID = Counter; } }
/// <summary> /// Change brush/color for given log entry type /// </summary> /// <param name="type"></param> /// <param name="brush"></param> public bool ChangeTypeColor(LogEntryTypes type, Brush brush) { if (brush == null) { return(false); } string typeNameWithBrush = type.ToString().ToLower().Trim('_') + "brush"; PropertyInfo[] properties = GetType().GetProperties(); foreach (PropertyInfo propertyInfo in properties) { string propertyNameString = propertyInfo.Name.ToLower(); if (propertyNameString == typeNameWithBrush) { if (propertyInfo.PropertyType == typeof(Brush)) { propertyInfo.SetValue(this, brush, null); return(true); } } } return(false); }
/// <summary> /// Deserialization /// </summary> /// <param name="entry"></param> /// <returns></returns> public static Log9KEntry FromByteArray(byte[] entry) { int i = 0; Buffer.BlockCopy(entry, i, _idBytes, 0, SIZE_ID); i += SIZE_ID; Buffer.BlockCopy(entry, i, _typeBytes, 0, SIZE_TYPE); i += SIZE_TYPE; LogEntryTypes type = (LogEntryTypes)_typeBytes[0]; Buffer.BlockCopy(entry, i, _levelBytes, 0, SIZE_LEVEL); i += SIZE_LEVEL; Buffer.BlockCopy(entry, i, _isDuplicateBytes, 0, SIZE_IS_DUPLICATE); i += SIZE_IS_DUPLICATE; Buffer.BlockCopy(entry, i, _unixTimeBytes, 0, SIZE_UNIX_TIME); i += SIZE_UNIX_TIME; Buffer.BlockCopy(entry, i, _millisecondsBytes, 0, SIZE_MILLISECONDS); i += SIZE_MILLISECONDS; if (type == LogEntryTypes.CUSTOM) { Buffer.BlockCopy(entry, i, _customTypeBytes, 0, SIZE_CUSTOM_TYPE); } i += SIZE_CUSTOM_TYPE; Buffer.BlockCopy(entry, i, _messageBytes, 0, SIZE_MESSAGE); uint id = BitConverter.ToUInt32(_idBytes, 0); Levels level = (Levels)_levelBytes[0]; bool isDuplicate = BitConverter.ToBoolean(_isDuplicateBytes, 0); uint unixTime = BitConverter.ToUInt32(_unixTimeBytes, 0); int milliseconds = BitConverter.ToInt32(_millisecondsBytes, 0); string message = Log9KUtil.GetString(_messageBytes); message = Log9KUtil.SplitStringWithNullEnding(message); string customType = Log9KUtil.GetString(_customTypeBytes); customType = Log9KUtil.SplitStringWithNullEnding(customType); Log9KEntry e = new Log9KEntry(type, message, new Log9KTime(unixTime, milliseconds)) { ID = id, CustomType = customType, IsDuplicate = isDuplicate, Level = level }; if (type == LogEntryTypes.CUSTOM) { e.TypeString = customType; } return(e); }
/// <summary> /// Log with Format, secondary level /// </summary> /// <param name="type"></param> /// <param name="format"></param> /// <param name="args"></param> /// <returns></returns> public bool LogSecondary_f(LogEntryTypes type, string format, params object[] args) { return(Log(type, string.Format(format, args), Levels.SECONDARY)); }
/// <summary> /// Log with Format /// </summary> /// <param name="type"></param> /// <param name="format"></param> /// <param name="args"></param> /// <returns></returns> public bool Log_f(LogEntryTypes type, string format, params object[] args) { return(Log(type, string.Format(format, args))); }
/// <summary> /// Get tab by given entry type /// </summary> /// <param name="tabType"></param> /// <returns></returns> private Log9KTab GetTab(LogEntryTypes tabType) { string tabTypeString = tabType.ToString(); return(GetTab(tabTypeString)); }