Bånder

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

$logger read-only

private LoggerInterface $logger
Tags
noinspection

PhpPropertyOnlyWrittenInspection

Attributes
#[LogChannel]
\App\Modules\Logging\Channel::Daily

Methods

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
throws
ValidationException

When parameters are invalid

response

array{ data: array{ lines: array, startLine: int, endLine: int, hasMore: boolean } }|array{error: string}

Attributes
#[Get]
'/{logFile}/content'
'api.logs.content'
Return values
JsonResponse

download()

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
throws
ModelNotFoundException

When log file is not found

response

BinaryFileResponse|array{error: string}

Attributes
#[Get]
'/{logFile}/download'
'api.logs.download'
Return values
BinaryFileResponse|JsonResponse

head()

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
throws
ValidationException

When lines parameter is invalid

response

array{ data: array{ content: array, showingLines: int } }|array{error: string}

Attributes
#[Get]
'/{logFile}/head'
'api.logs.head'
Return values
JsonResponse

index()

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
response

array<LogFile>

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
response

array{ data: array{ file: string, totalLines: int } }|array{error: string}

Attributes
#[Get]
'/{logFile}/lines'
'api.logs.lines'
Return values
JsonResponse

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
throws
ValidationException

When search parameters are invalid

response

array{ data: array{ pattern: string, caseSensitive: boolean, totalMatches: int, searchTimeMs: float, results: array<array{ lineNumber: int, content: string, matchPosition: int }> } }|array{error: string}

Attributes
#[Get]
'/{logFile}/search'
'api.logs.search'
Return values
JsonResponse

searchAll()

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
throws
ValidationException

When search parameters are invalid

response

array{ data: array{ pattern: string, caseSensitive: boolean, totalFilesSearched: int, filesWithMatches: int, totalMatches: int, searchTimeMs: float, results: array<array{ file: LogFile, results: array{ totalMatches: int, searchTimeMs: float, matches: array<array{ lineNumber: int, content: string, matchPosition: int }> } }> } }|array{error: string}

Attributes
#[Get]
'/search/all'
'api.logs.search-all'
Return values
JsonResponse

show()

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
throws
ModelNotFoundException

When log file is not found

response

array{ data: array{ file: LogFile, info: array{ size: int, lines: int, lastModified: string, isLargeFile: boolean, shouldUseThreading: boolean } } }|array{error: string}

Attributes
#[Get]
'/{logFile}'
'api.logs.show'
Return values
JsonResponse

stats()

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
response

array{ data: array{ fileInfo: array{ size: int, lines: int, lastModified: string }, logLevels: array{ error: int, warning: int, info: int, debug: int }, performance: array{ isLargeFile: boolean, shouldUseThreading: boolean, optimalThreads: int } } }|array{error: string}

Attributes
#[Get]
'/{logFile}/stats'
'api.logs.stats'
Return values
JsonResponse

tail()

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
throws
ValidationException

When lines parameter is invalid

response

array{ data: array{ content: array, totalLines: int, showingLines: int } }|array{error: string}

Attributes
#[Get]
'/{logFile}/tail'
'api.logs.tail'
Return values
JsonResponse

denyWithStatus()

protected denyWithStatus(string $message, int $status) : mixed
Parameters
$message : string
$status : int

gateCheckExecuteJob()

protected gateCheckExecuteJob() : mixed

gateCheckViewDashboard()

protected gateCheckViewDashboard() : mixed

        
On this page

Search results