Documentation

Log
in package

Mostly just level defs.

Table of Contents

Constants

LEVEL_DEBUG  : mixed = LOG_DEBUG
Put your noisey stuff in here.
LEVEL_ERROR  : mixed = LOG_ERR
No really, this is bad.
LEVEL_INFO  : mixed = LOG_INFO
Important things, but not verbose.
LEVEL_SILENT  : mixed = 0
Shh.
LEVEL_WARNING  : mixed = LOG_WARNING
Some needs to pay attention to this.

Methods

createFileLogger()  : callable
Create a logger method that writes messages to a file.
dump()  : void
Dump and die!
filter()  : callable
Filter a logger.
format()  : string
level()  : int
Get the level ID by it's name.
name()  : string
Get the friendly level name.
print()  : void
stringify()  : string
An attempt to convert things into strings.

Constants

LEVEL_DEBUG

Put your noisey stuff in here.

public mixed LEVEL_DEBUG = LOG_DEBUG

LEVEL_ERROR

No really, this is bad.

public mixed LEVEL_ERROR = LOG_ERR

LEVEL_INFO

Important things, but not verbose.

public mixed LEVEL_INFO = LOG_INFO

LEVEL_SILENT

Shh.

public mixed LEVEL_SILENT = 0

LEVEL_WARNING

Some needs to pay attention to this.

public mixed LEVEL_WARNING = LOG_WARNING

Methods

createFileLogger()

Create a logger method that writes messages to a file.

public static createFileLogger(string $path[, int $cache_size = 5 ][, array<string|int, int>|int $levels = null ]) : callable

The messages are cached in a in-memory queue to reduce disk activity. Disable it with a $cache_size = 1.

Parameters
$path : string

Write the file here (append mode)

$cache_size : int = 5

Only write to disk every 'x' messages

$levels : array<string|int, int>|int = null

Filtering; only log on these levels

Return values
callable —

(message, level, category)

dump()

Dump and die!

public static dump(mixed $thing) : void
Parameters
$thing : mixed

filter()

Filter a logger.

public static filter(callable|LogSinkInterface $logger[, int|null $level = null ][, string|array<string|int, mixed>|null $category = null ]) : callable

This wraps the logger function to filter on level or category.

// Only permit log levels higher than this:
// (excludes INFO, DEBUG, etc)
$loggable->attach($parent, Log::LEVEL_WARNING);

// Only permit this category:
$loggable->attach($parent, null, 'progress');

// Only permit these categories:
$loggable->attach($parent, null, ['log.request', 'log.response']);

// Exclude these categories:
$loggable->attach($parent, null, ['stats' => false, 'meta' => false]);
Parameters
$logger : callable|LogSinkInterface
$level : int|null = null
$category : string|array<string|int, mixed>|null = null
Return values
callable

format()

public static format(mixed $message, int $level, string $category, int $timestamp) : string
Parameters
$message : mixed
$level : int
$category : string
$timestamp : int
Return values
string

level()

Get the level ID by it's name.

public static level(string $name) : int
Parameters
$name : string
Return values
int

name()

Get the friendly level name.

public static name(int $level) : string
Parameters
$level : int
Return values
string

print()

public static print(mixed $message, int $level, string $category, int $timestamp) : void
Parameters
$message : mixed
$level : int
$category : string
$timestamp : int
Return values
void —
  • echoes to stdout

stringify()

An attempt to convert things into strings.

public static stringify(mixed $value[, int $indent = 0 ]) : string
Parameters
$value : mixed
$indent : int = 0
Return values
string
On this page

Search results