mirror of
https://github.com/riverar/messageanalyzer-archive
synced 2026-06-08 17:10:57 +00:00
77 lines
2.1 KiB
Plaintext
77 lines
2.1 KiB
Plaintext
const string normalRegex = @"(?<Date>[-/\.\:0-9]+\s[-/\.\:0-9]+)\s(?<Source>\w+):\s+(?<Message>.*)";
|
|
const string SQLServerSetup08Regex = "^" + normalRegex;
|
|
const string SQLServerSetup12OrLaterRegex = @"^\((?<FileId>\d\d)\)\s" + normalRegex;
|
|
|
|
// Parse messages when the SQL's version is not more than 2008
|
|
message SQLServerSetup08Entry : LogEntry
|
|
{
|
|
DateTime Date with EntryFieldInfo {IsTimestamp = true, IsLocalTime = true};
|
|
string Source;
|
|
string Message where ErrorCodeIf(value.IndexOf("Exception:") >= 0 || value.IndexOf("exception:") >= 0 , this, DiagnosisLevel.Error, value);
|
|
|
|
override string ToString()
|
|
{
|
|
return Message;
|
|
}
|
|
|
|
// one SQL Server log may exist in multiple lines
|
|
bool ParseContent(string line, LineContext context)
|
|
{
|
|
if (context.IsInitialLine)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (CanDecode<SQLServerSetup08Entry>(line, context))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
Message += " " + line.Trim();
|
|
|
|
return true;
|
|
}
|
|
}
|
|
with EntryInfo
|
|
{
|
|
Regex = SQLServerSetup08Regex,
|
|
Multiline = ParseContent
|
|
};
|
|
|
|
// Parse messages when the SQL's version is greater than or equal to 2012
|
|
message SQLServerSetup12OrLaterEntry : LogEntry
|
|
{
|
|
string FileId;
|
|
DateTime Date with EntryFieldInfo {IsTimestamp = true, IsLocalTime = true};
|
|
string Source;
|
|
string Message where ErrorCodeIf(value.IndexOf("Exception:") >= 0 || value.IndexOf("exception:") >= 0 , this, DiagnosisLevel.Error, value);
|
|
|
|
override string ToString()
|
|
{
|
|
return Message;
|
|
}
|
|
|
|
// one SQL Server log may exist in multiple lines
|
|
bool ParseContent(string line, LineContext context)
|
|
{
|
|
if (context.IsInitialLine)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (CanDecode<SQLServerSetup12OrLaterEntry>(line, context))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
Message += "\n" + line.Trim();
|
|
|
|
return true;
|
|
}
|
|
}
|
|
with EntryInfo
|
|
{
|
|
Regex = SQLServerSetup12OrLaterRegex,
|
|
Multiline = ParseContent
|
|
};
|