Biblionet API Wrapper

Logger

A helper class to output logs.

Tags
todo

Add extra output options: file, mail etc

todo

handle errors with exit codes

author

Panagiotis Pantazopoulos takispadaz@gmail.com

Table of Contents

ERROR  = 'error'
Error log type
INFO  = 'info'
Info log type
SUCCESS  = 'success'
Success log type
WARNING  = 'warning'
Warning log type
$colors  : array<string|int, mixed>
The colors for each log type. For cli or web server output.
$debug  : bool
logs enabled or not
$show  : array<string|int, mixed>
The log types to handle
__construct()  : mixed
Constructor.
disable()  : void
Disables the logging
enable()  : void
Enables the logging
log()  : void
Logs an entry.

Constants

ERROR

Error log type

public mixed ERROR = 'error'

INFO

Info log type

public mixed INFO = 'info'

SUCCESS

Success log type

public mixed SUCCESS = 'success'

WARNING

Warning log type

public mixed WARNING = 'warning'

Properties

$colors

The colors for each log type. For cli or web server output.

private array<string|int, mixed> $colors = [self::SUCCESS => ["CLI" => "32m", "WEB" => "#00FF00"], self::ERROR => ["CLI" => "31m", "WEB" => "#FF0000"], self::INFO => ["CLI" => "34m", "WEB" => "#0000FF"], self::WARNING => ["CLI" => "33m", "WEB" => "#FFFF00"]]

$debug

logs enabled or not

private bool $debug

$show

The log types to handle

private array<string|int, mixed> $show = []

Methods

__construct()

Constructor.

public __construct([array<string|int, mixed> $show = [self::SUCCESS, self::ERROR, self::INFO, self::WARNING] ]) : mixed
Parameters
$show : array<string|int, mixed> = [self::SUCCESS, self::ERROR, self::INFO, self::WARNING]

An array with the error types to be handled by the class

Return values
mixed

disable()

Disables the logging

public disable() : void
Return values
void

enable()

Enables the logging

public enable() : void
Return values
void

log()

Logs an entry.

public log(string $type, string $entity, string $title[, string $text = "" ][, string $percentage = NULL ]) : void
Parameters
$type : string

The type of the log entry

$entity : string
$title : string

A title describing the log entry

$text : string = ""

A description for the log entry

$percentage : string = NULL

A value indicating the percentage of completion

Return values
void

Search results