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