WL#17345: Server error logs viewer

Affects: MySQL-Shell-26.x   —   Status: Complete

Overview

Add an Error Log page to the MySQL administration workspace. The page presents server error-log entries in a paginated table and provides filtering, refresh, source selection, and export actions.

Design

For an active connection, the page reads performance_schema.error_log through the administration service session. A local connection can instead read the traditional-format error-log file through the gui.mysql backend.

The backend caches log_error, log_error_services, and the server variables needed to resolve the sink's file whenever a saved connection is opened. This allows the same file source to be used from an offline administration workspace.

The selected source owns its paging and filtering state. Export uses the desktop save-file flow and delegates to the export operation for that source.

  • FR1: The administration workspace shall provide an Error Log page showing timestamp, priority, error code, subsystem, and message.
  • FR2: For an active connection, the page shall display entries from performance_schema.error_log with the newest entries first.
  • FR3: For a local connection with a traditional-format error-log file, the page shall display that file when the Performance Schema source is unavailable or the server is offline.
  • FR4: The page shall provide first, previous, next, and last page navigation and shall refresh the current page on request.
  • FR5: The page shall filter entries by timestamp, priority, error code, subsystem, and message before pagination.
  • FR6: For an online local connection, the page shall allow switching between the Performance Schema table and the error log file.
  • FR7: The page shall export the complete selected log source to a user-selected file.

WL#17345: Server Error Log Viewer

Administration Page

The logs administration page uses the active SQL editor session for table-backed logs and the MySQL backend for file-backed logs.

The local file source is resolved from @@log_error and @@log_error_services. It is available when log_sink_internal is configured and log_error names a file; its path is the log_error value. When the server is offline, the values cached automatically on connect are used.

The page size is 1,000 entries. Table entries are ordered by timestamp in descending order. File entries retain their original order, and the initial file view opens on the last page.

Filtering

The filter editor provides a relative timestamp range, one or more priorities, one or more error codes, one or more subsystems, and a message substring. Priority choices are fixed. Error-code and subsystem choices are populated from the selected source.

Filters in different fields are combined with AND. Multiple values selected within one field are combined with OR. Priority and message matching is case-insensitive; error-code and subsystem matching is exact.

Filter edits are applied when the user selects Apply. Applying or resetting the filters loads the first page, and filtering occurs before pagination for both sources. Previous Match and Next Match use the current edits to highlight matching rows on the displayed page without applying the filters.

For the table source, the filter is added to the parameterized count and data queries. For the file source, the filter is passed to gui.mysql.readErrorLogFilePage, which counts matching entries and returns the requested page from that filtered result.

File Page API

The MySQL backend adds:

gui.mysql.readErrorLogFilePage(
    moduleSessionId,
    page = 0,
    pageSize = 1000,
    filters = undefined
)

filters may contain:

{
    minTimestamp?: number, // Unix timestamp in seconds
    priorities?: string[],
    errorCodes?: string[],
    subsystems?: string[],
    message?: string
}

The result contains the source path, page information, truncation status, available error-code and subsystem values, and parsed log rows.

Export APIs

The MySQL backend adds:

gui.mysql.exportErrorLogFile(moduleSessionId, targetPath)

gui.mysql.exportErrorLogs(targetPath, moduleSessionId)

File export copies the source file. Table export writes all performance_schema.error_log rows as text entries in descending timestamp order. moduleSessionId identifies the profile-bound SQL editor module session. File operations use its saved connection, and table export uses its database service session.

Cached Server Data

Opening a connection to an online MySQL server refreshes a backend-owned cache of server identity, version, directory, and logging variables. The cache is stored as JSON in db_connection.internal_data and is used by the offline Server Status and Error Log pages.

The local error-log path is resolved from the cached log_error and log_error_services values. A relative path is resolved against the cached datadir value.