File
extends AbstractStorage
in package
Debug file storage class
Tags
Table of Contents
Constants
- FORMATS = ['csv', 'tsv', 'ndjson']
- Supported formats
Properties
Methods
- __construct() : mixed
- Constructor
- clear() : void
- Clear all debug data
- getDir() : string|null
- Get the storage dir
- getFormat() : string
- Get the format
- hasDir() : bool
- Has storage dir
- prepareEvents() : array<string|int, mixed>
- Prepare events
- save() : void
- Save debug data
- setDir() : File
- Set the current storage dir
- setFormat() : File
- Set the format
- appendNdJsonToFile() : void
- Append events to an NDJSON (JSON Lines) file, one self-contained JSON object per line
Constants
FORMATS
Supported formats
protected
array<string|int, mixed>
FORMATS
= ['csv', 'tsv', 'ndjson']
Properties
$dir
Storage dir
protected
string|null
$dir
= null
$format
Format (csv, tsv or ndjson)
protected
string
$format
= 'csv'
Methods
__construct()
Constructor
public
__construct(string $dir[, string $format = 'csv' ]) : mixed
Instantiate the file storage object
Parameters
- $dir : string
- $format : string = 'csv'
clear()
Clear all debug data
public
clear() : void
getDir()
Get the storage dir
public
getDir() : string|null
Return values
string|nullgetFormat()
Get the format
public
getFormat() : string
Return values
stringhasDir()
Has storage dir
public
hasDir() : bool
Return values
boolprepareEvents()
Prepare events
public
prepareEvents(string $id, string $name, AbstractHandler $handler) : array<string|int, mixed>
Parameters
- $id : string
- $name : string
- $handler : AbstractHandler
Return values
array<string|int, mixed>save()
Save debug data
public
save(string $id, string $name, AbstractHandler $handler) : void
Parameters
- $id : string
- $name : string
- $handler : AbstractHandler
setDir()
Set the current storage dir
public
setDir(string $dir) : File
Parameters
- $dir : string
Tags
Return values
FilesetFormat()
Set the format
public
setFormat(string $format) : File
Parameters
- $format : string
Tags
Return values
FileappendNdJsonToFile()
Append events to an NDJSON (JSON Lines) file, one self-contained JSON object per line
protected
appendNdJsonToFile(string $filename, array<string|int, mixed> $events) : void
The 'context' field of each event is already a json_encode()'d string (see AbstractStorage::prepareEvents(), shared with the CSV/TSV formats, where it needs to be a flat scalar cell). For NDJSON it's decoded back into a real nested value first, so it comes out as proper nested JSON instead of a doubly-escaped string.
Parameters
- $filename : string
- $events : array<string|int, mixed>