LogsController
extends Controller
in package
Application log file management and analysis controller
Provides comprehensive log file operations including viewing, searching, downloading, and statistical analysis. Supports high-performance operations on large log files with threading and optimized search capabilities.
Attributes
- #[Middleware]
- ['auth:sanctum', 'ability:' . \App\Models\TokenAbility::ACCESS_API->value, 'force.json']
- #[Prefix]
- '/logs'
Table of Contents
Properties
- $logFileService : LogFileService
- $logger : LoggerInterface
Methods
- __construct() : mixed
- content() : JsonResponse
- Get paginated content from a log file
- download() : BinaryFileResponse|JsonResponse
- Download a log file
- head() : JsonResponse
- Get the first N lines from a log file (head functionality)
- index() : array<string|int, mixed>
- Get a collection of available log files
- lines() : JsonResponse
- Count total lines in a log file
- search() : JsonResponse
- Search for patterns within a log file
- searchAll() : JsonResponse
- Search across multiple log files simultaneously
- show() : JsonResponse
- Get detailed information about a specific log file
- stats() : JsonResponse
- Get comprehensive statistics for a log file
- tail() : JsonResponse
- Get the last N lines from a log file (tail functionality)
- denyWithStatus() : mixed
- gateCheckExecuteJob() : mixed
- gateCheckViewDashboard() : mixed
- noContent() : mixed
Properties
$logFileService read-only
private
LogFileService
$logFileService
$logger read-only
private
LoggerInterface
$logger
Tags
Attributes
- #[LogChannel]
- \App\Modules\Logging\Channel::Daily
Methods
__construct()
public
__construct(LogFileService $logFileService) : mixed
Parameters
- $logFileService : LogFileService
content()
Get paginated content from a log file
public
content(Request $request, string $logFile) : JsonResponse
Retrieves log file content starting from a specific line number with configurable line limits for efficient pagination through large files.
Parameters
- $request : Request
-
Request with optional after_line and max_lines parameters
- $logFile : string
-
The log file identifier
Tags
Attributes
- #[Get]
- '/{logFile}/content'
- 'api.logs.content'
Return values
JsonResponsedownload()
Download a log file
public
download(string $logFile) : BinaryFileResponse|JsonResponse
Provides direct download access to log files for offline analysis or archival purposes. Returns the file as a plain text download.
Parameters
- $logFile : string
-
The log file identifier to download
Tags
Attributes
- #[Get]
- '/{logFile}/download'
- 'api.logs.download'
Return values
BinaryFileResponse|JsonResponsehead()
Get the first N lines from a log file (head functionality)
public
head(Request $request, string $logFile) : JsonResponse
Returns the first lines from a log file, similar to the Unix head command. Useful for examining log file structure and initial entries.
Parameters
- $request : Request
-
Request with optional lines parameter
- $logFile : string
-
The log file identifier
Tags
Attributes
- #[Get]
- '/{logFile}/head'
- 'api.logs.head'
Return values
JsonResponseindex()
Get a collection of available log files
public
index() : array<string|int, mixed>
Returns a sorted list of all available log files in the system with metadata including file sizes, modification dates, and identifiers.
Tags
Attributes
- #[Get]
- '/'
- 'api.logs.index'
Return values
array<string|int, mixed>lines()
Count total lines in a log file
public
lines(string $logFile) : JsonResponse
Returns the total line count for a log file using optimized counting algorithms that can handle very large files efficiently.
Parameters
- $logFile : string
-
The log file identifier
Tags
Attributes
- #[Get]
- '/{logFile}/lines'
- 'api.logs.lines'
Return values
JsonResponsesearch()
Search for patterns within a log file
public
search(Request $request, string $logFile) : JsonResponse
Performs high-performance pattern matching within log files with support for case-sensitive/insensitive searches and configurable result limits.
Parameters
- $request : Request
-
Request with pattern, caseSensitive, and maxResults parameters
- $logFile : string
-
The log file identifier to search
Tags
Attributes
- #[Get]
- '/{logFile}/search'
- 'api.logs.search'
Return values
JsonResponsesearchAll()
Search across multiple log files simultaneously
public
searchAll(Request $request) : JsonResponse
Performs pattern matching across multiple log files in parallel, providing consolidated search results with performance metrics and per-file result breakdowns.
Parameters
- $request : Request
-
Request with search parameters and optional file filtering
Tags
Attributes
- #[Get]
- '/search/all'
- 'api.logs.search-all'
Return values
JsonResponseshow()
Get detailed information about a specific log file
public
show(string $logFile) : JsonResponse
Returns comprehensive metadata about a log file including file statistics, line counts, size information, and performance characteristics.
Parameters
- $logFile : string
-
The log file identifier
Tags
Attributes
- #[Get]
- '/{logFile}'
- 'api.logs.show'
Return values
JsonResponsestats()
Get comprehensive statistics for a log file
public
stats(string $logFile) : JsonResponse
Analyzes log file content to provide detailed statistics including log level counts, performance metrics, and optimization recommendations.
Parameters
- $logFile : string
-
The log file identifier
Tags
Attributes
- #[Get]
- '/{logFile}/stats'
- 'api.logs.stats'
Return values
JsonResponsetail()
Get the last N lines from a log file (tail functionality)
public
tail(Request $request, string $logFile) : JsonResponse
Returns the most recent lines from a log file, similar to the Unix tail command. Useful for monitoring recent activity and debugging current issues.
Parameters
- $request : Request
-
Request with optional lines parameter
- $logFile : string
-
The log file identifier
Tags
Attributes
- #[Get]
- '/{logFile}/tail'
- 'api.logs.tail'
Return values
JsonResponsedenyWithStatus()
protected
denyWithStatus(string $message, int $status) : mixed
Parameters
- $message : string
- $status : int
gateCheckExecuteJob()
protected
gateCheckExecuteJob() : mixed
gateCheckViewDashboard()
protected
gateCheckViewDashboard() : mixed
noContent()
protected
noContent() : mixed