mirror of
https://github.com/acidanthera/OpenCorePkg.git
synced 2025-12-08 19:25:01 +00:00
OcLog: Update filtering
- Filter log strings after formatting - Never filter WARN and ERROR log lines - Fix positive filtering - Fix minor issue in valid log prefix algorithm
This commit is contained in:
parent
0083a4ef15
commit
47a3da4822
@ -16,6 +16,7 @@ OpenCore Changelog
|
||||
- Fixed regression for ACPI quirks `RebaseRegions` and `SyncTableIds`
|
||||
- Updated build process to provide stable and bleeding-edge versions of `EnableGop`
|
||||
- Implemented minor improvements in `PickerMode` `Apple`
|
||||
- Improved filtering algorithm for `LogModules` option
|
||||
|
||||
#### v0.9.1
|
||||
- Fixed long comment printing for ACPI patches, thx @corpnewt
|
||||
|
||||
@ -1 +1 @@
|
||||
bb8e83abb7655428a8fb6fc902cc0373
|
||||
97c56a093dd641371080fd3594c39713
|
||||
|
||||
Binary file not shown.
@ -3889,6 +3889,9 @@ cat Kernel.panic | grep macOSProcessedStackshotData |
|
||||
\emph{Note 2}: Messages printed before the configuration of log protocol
|
||||
cannot be filtered.
|
||||
|
||||
\emph{Note 3}: To avoid missing key issues, warning and error log messages
|
||||
are not filtered.
|
||||
|
||||
\item
|
||||
\texttt{SysReport}\\
|
||||
\textbf{Type}: \texttt{plist\ boolean}\\
|
||||
|
||||
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
\documentclass[]{article}
|
||||
%DIF LATEXDIFF DIFFERENCE FILE
|
||||
%DIF DEL PreviousConfiguration.tex Wed Apr 5 14:22:58 2023
|
||||
%DIF ADD ../Configuration.tex Sat May 6 18:57:47 2023
|
||||
%DIF DEL PreviousConfiguration.tex Fri May 5 21:18:04 2023
|
||||
%DIF ADD ../Configuration.tex Sun May 7 11:45:23 2023
|
||||
|
||||
\usepackage{lmodern}
|
||||
\usepackage{amssymb,amsmath}
|
||||
@ -3960,7 +3960,11 @@ cat Kernel.panic | grep macOSProcessedStackshotData |
|
||||
\emph{Note 2}: Messages printed before the configuration of log protocol
|
||||
cannot be filtered.
|
||||
|
||||
\item
|
||||
\DIFaddbegin \emph{\DIFadd{Note 3}}\DIFadd{: To avoid missing key issues, warning and error log messages
|
||||
are not filtered.
|
||||
}
|
||||
|
||||
\DIFaddend \item
|
||||
\texttt{SysReport}\\
|
||||
\textbf{Type}: \texttt{plist\ boolean}\\
|
||||
\textbf{Failsafe}: \texttt{false}\\
|
||||
|
||||
Binary file not shown.
@ -143,59 +143,67 @@ GetLogPath (
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
GetLogPrefix (
|
||||
IN CONST CHAR8 *FormatString,
|
||||
IN CONST CHAR8 *FormattedString,
|
||||
OUT CHAR8 *Prefix
|
||||
)
|
||||
{
|
||||
UINTN MaxLength;
|
||||
UINTN Index;
|
||||
CHAR8 Curr;
|
||||
UINTN Pos;
|
||||
CHAR8 Char;
|
||||
|
||||
ASSERT (FormatString != NULL);
|
||||
ASSERT (FormattedString != NULL);
|
||||
ASSERT (Prefix != NULL);
|
||||
|
||||
//
|
||||
// If FormatString just starts with colon, it must be illegal.
|
||||
//
|
||||
if (*FormatString == ':') {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
Pos = 0;
|
||||
while (TRUE) {
|
||||
Char = FormattedString[Pos];
|
||||
|
||||
MaxLength = MIN (AsciiStrLen (FormatString), OC_LOG_PREFIX_CHAR_MAX);
|
||||
for (Index = 1; Index < MaxLength; ++Index) {
|
||||
Curr = FormatString[Index];
|
||||
//
|
||||
// If we reached end of string, then ':' was not found.
|
||||
//
|
||||
if (Char == '\0') {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
//
|
||||
// Match the first occurrence of colon.
|
||||
//
|
||||
if (Curr == ':') {
|
||||
if (Char == ':') {
|
||||
//
|
||||
// If log string starts with colon, it must be illegal.
|
||||
//
|
||||
if (Pos == 0) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// If size of prefix would exceed OC_LOG_PREFIX_CHAR_MAX, then not found.
|
||||
//
|
||||
if (Pos == OC_LOG_PREFIX_CHAR_MAX) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
//
|
||||
// Except for colon, a valid prefix must be either 0-9, or uppercase letter.
|
||||
//
|
||||
if (!(IsAsciiNumber (Curr) || ((Curr >= 'A') && (Curr <= 'Z')))) {
|
||||
if (!(IsAsciiNumber (Char) || ((Char >= 'A') && (Char <= 'Z')))) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
++Pos;
|
||||
}
|
||||
|
||||
//
|
||||
// If Index went through the end, then ':' was not found.
|
||||
//
|
||||
if (Index == MaxLength) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
CopyMem (Prefix, FormatString, Index);
|
||||
Prefix[Index] = '\0';
|
||||
CopyMem (Prefix, FormattedString, Pos);
|
||||
Prefix[Pos] = '\0';
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
STATIC
|
||||
BOOLEAN
|
||||
IsPrefixFiltered (
|
||||
IN CONST CHAR8 *FormatString,
|
||||
IN CONST CHAR8 *FormattedString,
|
||||
IN CONST OC_FLEX_ARRAY *FlexFilters OPTIONAL,
|
||||
IN BOOLEAN BlacklistFiltering
|
||||
)
|
||||
@ -205,16 +213,16 @@ IsPrefixFiltered (
|
||||
EFI_STATUS Status;
|
||||
CHAR8 **Value;
|
||||
|
||||
ASSERT (FormatString != NULL);
|
||||
ASSERT (FormattedString != NULL);
|
||||
|
||||
//
|
||||
// Do not filter without filters, of course.
|
||||
// Do not filter without filters.
|
||||
//
|
||||
if (FlexFilters == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Status = GetLogPrefix (FormatString, Prefix);
|
||||
Status = GetLogPrefix (FormattedString, Prefix);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -225,14 +233,16 @@ IsPrefixFiltered (
|
||||
|
||||
if (AsciiStrCmp (Prefix, *Value) == 0) {
|
||||
//
|
||||
// Upon matching, return TRUE (i.e. not to print logs)
|
||||
// if blacklisted.
|
||||
// Upon matching, return TRUE (i.e. not to print logs) if blacklisted.
|
||||
//
|
||||
return BlacklistFiltering;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
//
|
||||
// Otherwise return default, depending on positive or negative filtering.
|
||||
//
|
||||
return !BlacklistFiltering;
|
||||
}
|
||||
|
||||
STATIC
|
||||
@ -241,6 +251,8 @@ InternalLogAddEntry (
|
||||
IN OC_LOG_PRIVATE_DATA *Private,
|
||||
IN OC_LOG_PROTOCOL *OcLog,
|
||||
IN UINTN ErrorLevel,
|
||||
IN CONST OC_FLEX_ARRAY *FlexFilters OPTIONAL,
|
||||
IN BOOLEAN BlacklistFiltering,
|
||||
IN CONST CHAR8 *FormatString,
|
||||
IN VA_LIST Marker
|
||||
)
|
||||
@ -263,6 +275,15 @@ InternalLogAddEntry (
|
||||
Marker
|
||||
);
|
||||
|
||||
//
|
||||
// Filter log after formatting string. Always log at WARN and ERROR level.
|
||||
//
|
||||
if ( ((ErrorLevel & (DEBUG_WARN | DEBUG_ERROR)) == 0)
|
||||
&& IsPrefixFiltered (Private->LineBuffer, Private->FlexFilters, Private->BlacklistFiltering))
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// Add Entry.
|
||||
//
|
||||
@ -480,7 +501,6 @@ OcLogAddEntry (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
OC_LOG_PRIVATE_DATA *Private;
|
||||
BOOLEAN IsFiltered;
|
||||
|
||||
ASSERT (OcLog != NULL);
|
||||
ASSERT (FormatString != NULL);
|
||||
@ -494,14 +514,7 @@ OcLogAddEntry (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// Filter log.
|
||||
//
|
||||
Status = EFI_SUCCESS;
|
||||
IsFiltered = IsPrefixFiltered (FormatString, Private->FlexFilters, Private->BlacklistFiltering);
|
||||
if (!IsFiltered) {
|
||||
Status = InternalLogAddEntry (Private, OcLog, ErrorLevel, FormatString, Marker);
|
||||
}
|
||||
Status = InternalLogAddEntry (Private, OcLog, ErrorLevel, Private->FlexFilters, Private->BlacklistFiltering, FormatString, Marker);
|
||||
|
||||
if ( ((ErrorLevel & OcLog->HaltLevel) != 0)
|
||||
&& (AsciiStrnCmp (FormatString, "\nASSERT_RETURN_ERROR", L_STR_LEN ("\nASSERT_RETURN_ERROR")) != 0)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user