You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
254 lines
6.4 KiB
254 lines
6.4 KiB
namespace LTEMvcApp.Models
|
|
{
|
|
/// <summary>
|
|
/// 日志常量
|
|
/// </summary>
|
|
public static class LogConstants
|
|
{
|
|
#region 全局常量
|
|
|
|
/// <summary>
|
|
/// 最大日志数量
|
|
/// </summary>
|
|
public const int LOGS_MAX = 2000000;
|
|
|
|
/// <summary>
|
|
/// 日志范围
|
|
/// </summary>
|
|
public static readonly List<long[]> LOGS_RANGE = new();
|
|
|
|
/// <summary>
|
|
/// 日志信息
|
|
/// </summary>
|
|
public static readonly List<int> LOGS_INFO = new();
|
|
|
|
/// <summary>
|
|
/// 日志层
|
|
/// </summary>
|
|
public static readonly List<string> LOGS_LAYERS = new();
|
|
|
|
/// <summary>
|
|
/// 导出时间格式
|
|
/// </summary>
|
|
public static string EXPORT_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss.fff";
|
|
|
|
/// <summary>
|
|
/// 是否启用内联缓存
|
|
/// </summary>
|
|
public static bool INLINE_CACHE_ENABLED = false;
|
|
|
|
#endregion
|
|
|
|
#region 应用模式
|
|
|
|
/// <summary>
|
|
/// 应用模式
|
|
/// </summary>
|
|
public static class AppMode
|
|
{
|
|
public const string Web = "web";
|
|
public const string App = "app";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出模式
|
|
/// </summary>
|
|
public static class ExportMode
|
|
{
|
|
public const string Zip = "zip";
|
|
public const string Text = "text";
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 字体和样式
|
|
|
|
/// <summary>
|
|
/// 默认字体
|
|
/// </summary>
|
|
public const string DEFAULT_FONT = "13px helvetica, arial, verdana, sans-serif";
|
|
|
|
/// <summary>
|
|
/// 默认颜色
|
|
/// </summary>
|
|
public const string DEFAULT_COLOR = "#000000";
|
|
|
|
#endregion
|
|
|
|
#region 时间相关
|
|
|
|
/// <summary>
|
|
/// 时间戳基准(2000-01-01 00:00:00)
|
|
/// </summary>
|
|
public const long TIMESTAMP_BASE = 946681200000;
|
|
|
|
/// <summary>
|
|
/// 默认时间原点
|
|
/// </summary>
|
|
public const string DEFAULT_TIME_ORIGIN = "00:00:00.000";
|
|
|
|
#endregion
|
|
|
|
#region 客户端相关
|
|
|
|
/// <summary>
|
|
/// 默认重连延迟(毫秒)
|
|
/// </summary>
|
|
public const int DEFAULT_RECONNECT_DELAY = 2500;
|
|
|
|
/// <summary>
|
|
/// 默认重连延迟(毫秒)
|
|
/// </summary>
|
|
public const int DEFAULT_RECONNECT_DELAY_APP = 5000;
|
|
|
|
/// <summary>
|
|
/// HFN回绕阈值
|
|
/// </summary>
|
|
public const int HFN_WRAP_THRESHOLD = 512;
|
|
|
|
#endregion
|
|
|
|
#region 日志级别
|
|
|
|
/// <summary>
|
|
/// 日志级别名称
|
|
/// </summary>
|
|
public static readonly string[] LOG_LEVEL_NAMES = { "none", "error", "warn", "info", "debug" };
|
|
|
|
/// <summary>
|
|
/// 日志方法名称
|
|
/// </summary>
|
|
public static readonly string[] LOG_METHODS = { "error", "warn", "info", "debug", "prof" };
|
|
|
|
#endregion
|
|
|
|
#region 性能相关
|
|
|
|
/// <summary>
|
|
/// 大日志列表阈值
|
|
/// </summary>
|
|
public const int LARGE_LOG_THRESHOLD = 500000;
|
|
|
|
/// <summary>
|
|
/// 小日志列表阈值
|
|
/// </summary>
|
|
public const int SMALL_LOG_THRESHOLD = 50000;
|
|
|
|
/// <summary>
|
|
/// 日志模块列表最大长度
|
|
/// </summary>
|
|
public const int LOG_MODULE_LIST_MAX = 20;
|
|
|
|
#endregion
|
|
|
|
#region 文件相关
|
|
|
|
/// <summary>
|
|
/// 支持的文件类型
|
|
/// </summary>
|
|
public static class FileTypes
|
|
{
|
|
public const string Binary = "bin";
|
|
public const string Base64 = "base64";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 文件大小单位
|
|
/// </summary>
|
|
public static class FileSizeUnits
|
|
{
|
|
public const string Kilobyte = "K";
|
|
public const string Megabyte = "M";
|
|
public const string Gigabyte = "G";
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 正则表达式
|
|
|
|
/// <summary>
|
|
/// 参数解析正则表达式
|
|
/// </summary>
|
|
public const string PARAMS_REGEX = @"\s*([^=]+)=([^,\s]+)";
|
|
|
|
#endregion
|
|
|
|
#region 事件相关
|
|
|
|
/// <summary>
|
|
/// 事件类型
|
|
/// </summary>
|
|
public static class EventTypes
|
|
{
|
|
public const string NewLogs = "newLogs";
|
|
public const string SelectLog = "selectLog";
|
|
public const string All = "*";
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 浏览器相关
|
|
|
|
/// <summary>
|
|
/// 鼠标滚轮事件
|
|
/// </summary>
|
|
public static class MouseWheelEvents
|
|
{
|
|
public const string Firefox = "DOMMouseScroll";
|
|
public const string Other = "mousewheel";
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 工具方法
|
|
|
|
/// <summary>
|
|
/// 获取日志级别名称
|
|
/// </summary>
|
|
/// <param name="level">级别值</param>
|
|
/// <returns>级别名称</returns>
|
|
public static string GetLogLevelName(int level)
|
|
{
|
|
if (level >= 0 && level < LOG_LEVEL_NAMES.Length)
|
|
return LOG_LEVEL_NAMES[level];
|
|
return "unknown";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取日志级别值
|
|
/// </summary>
|
|
/// <param name="levelName">级别名称</param>
|
|
/// <returns>级别值</returns>
|
|
public static int GetLogLevelValue(string levelName)
|
|
{
|
|
for (int i = 0; i < LOG_LEVEL_NAMES.Length; i++)
|
|
{
|
|
if (LOG_LEVEL_NAMES[i] == levelName)
|
|
return i;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 检查是否为持续时间戳
|
|
/// </summary>
|
|
/// <param name="timestamp">时间戳</param>
|
|
/// <returns>是否为持续时间</returns>
|
|
public static bool IsDurationTimestamp(long timestamp)
|
|
{
|
|
return timestamp < TIMESTAMP_BASE;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取默认重连延迟
|
|
/// </summary>
|
|
/// <param name="mode">应用模式</param>
|
|
/// <returns>重连延迟</returns>
|
|
public static int GetDefaultReconnectDelay(string mode)
|
|
{
|
|
return mode == AppMode.App ? DEFAULT_RECONNECT_DELAY_APP : DEFAULT_RECONNECT_DELAY;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|