PHP 클래스 SimpleLogger

Example of stderr logger: $logger = new SimpleLogger(fopen('php://stderr', 1)); $logger->warn('You are a monkey');
저자: Rasmus Andersson http://hunch.se/
파일 보기 프로젝트 열기: bonny/wordpress-simple-history 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$lastInsertID ID of last inserted row. Used when chaining methods.
$messages By adding your messages here they will be stored both translated and non-translated You then log something like this: $this->info( $this->messages["POST_UPDATED"] ); or with the shortcut $this->infoMessage("POST_UPDATED"); which results in the original, untranslated, string being added to the log and database the translated string are then only used when showing the log in the GUI
$slug Unique slug for this logger Will be saved in DB and used to associate each log row with its logger

공개 메소드들

메소드 설명
__construct ( $simpleHistory = null ) Constructor. Remember to call this as parent constructor if making a childlogger
adminCSS ( ) Override this to add CSS in for your logger.
adminJS ( ) Override this to add JavaScript in the footer for your logger.
alert ( string $message, array $context = [] ) : null Action must be taken immediately.
alertMessage ( string $message, array $context = [] ) : null Action must be taken immediately.
critical ( string $message, array $context = [] ) : null Critical conditions.
criticalMessage ( string $message, array $context = [] ) : null Critical conditions.
debug ( string $message, array $context = [] ) : null Detailed debug information.
debugMessage ( string $message, array $context = [] ) : null Detailed debug information.
emergency ( string $message, array $context = [] ) : null System is unusable.
emergencyMessage ( string $message, array $context = [] ) : null System is unusable.
error ( string $message, array $context = [] ) : null Runtime errors that do not require immediate action but should typically be logged and monitored.
errorMessage ( string $message, array $context = [] ) : null Runtime errors that do not require immediate action but should typically be logged and monitored.
getCapability ( ) Returns the capability required to read log rows from this logger
getInfo ( ) : array Get array with information about this logger
getInfoValueByKey ( $key ) : Mixed Return single array entry from the array in getInfo() Returns the value of the key if value exists, or null
getLogRowDetailsOutput ( object $row ) : string Use this method to output detailed output for a log row Example usage is if a user has uploaded an image then a thumbnail of that image can bo outputed here
getLogRowHeaderOutput ( $row ) : string Returns header output for a log row Format should be common for all log rows and should be like: Username (user role) · Date
getLogRowPlainTextOutput ( $row ) Returns the plain text version of this entry Used in for example CSV-exports.
getLogRowSenderImageOutput ( $row ) Get output for image Image can be for example gravar if sender is user, or other images if sender i system, wordpress, and so on
get_event_ip_number_headers ( $row ) Returns additional headers with ip number from context
get_ip_number_header_keys ( ) Returns array with headers that may contain user IP
info ( string $message, array $context = [] ) : null Interesting events.
infoMessage ( string $message, array $context = [] ) : null Interesting events.
interpolate ( string $message, array $context = [], array $row = null ) Interpolates context values into the message placeholders.
loaded ( ) Method that is called automagically when logger is loaded by Simple History Add your init stuff here
log ( mixed $level, string $message, array $context = [] ) : null Logs with an arbitrary level.
notice ( string $message, array $context = [] ) : null Normal but significant events.
noticeMessage ( string $message, array $context = [] ) : null Normal but significant events.
validate_ip ( $ip ) Ensures an ip address is both a valid IP and does not fall within a private network range.
warning ( string $message, array $context = [] ) : null Exceptional occurrences that are not errors.
warningMessage ( string $message, array $context = [] ) : null Exceptional occurrences that are not errors.

비공개 메소드들

메소드 설명
logByMessageKey ( $SimpleLoggerLogLevelsLevel, $messageKey, $context ) Log with message Called from infoMessage(), errorMessage(), and so on

메소드 상세

__construct() 공개 메소드

Constructor. Remember to call this as parent constructor if making a childlogger
public __construct ( $simpleHistory = null )
$simpleHistory history class objectinstance

adminCSS() 공개 메소드

The CSS that you output will only be outputed on pages where Simple History is used.
public adminCSS ( )

adminJS() 공개 메소드

The JS that you output will only be outputed on pages where Simple History is used.
public adminJS ( )

alert() 공개 정적인 메소드

Action must be taken immediately.
public static alert ( string $message, array $context = [] ) : null
$message string
$context array
리턴 null

alertMessage() 공개 메소드

Action must be taken immediately.
public alertMessage ( string $message, array $context = [] ) : null
$message string key from getInfo messages array
$context array
리턴 null

critical() 공개 정적인 메소드

Example: Application component unavailable, unexpected exception.
public static critical ( string $message, array $context = [] ) : null
$message string
$context array
리턴 null

criticalMessage() 공개 메소드

Critical conditions.
public criticalMessage ( string $message, array $context = [] ) : null
$message string key from getInfo messages array
$context array
리턴 null

debug() 공개 메소드

Detailed debug information.
public debug ( string $message, array $context = [] ) : null
$message string
$context array
리턴 null

debugMessage() 공개 메소드

Detailed debug information.
public debugMessage ( string $message, array $context = [] ) : null
$message string key from getInfo messages array
$context array
리턴 null

emergency() 공개 정적인 메소드

System is unusable.
public static emergency ( string $message, array $context = [] ) : null
$message string
$context array
리턴 null

emergencyMessage() 공개 메소드

System is unusable.
public emergencyMessage ( string $message, array $context = [] ) : null
$message string key from getInfo messages array
$context array
리턴 null

error() 공개 메소드

Runtime errors that do not require immediate action but should typically be logged and monitored.
public error ( string $message, array $context = [] ) : null
$message string
$context array
리턴 null

errorMessage() 공개 메소드

Runtime errors that do not require immediate action but should typically be logged and monitored.
public errorMessage ( string $message, array $context = [] ) : null
$message string key from getInfo messages array
$context array
리턴 null

getCapability() 공개 메소드

Returns the capability required to read log rows from this logger
public getCapability ( )

getInfo() 공개 메소드

Get array with information about this logger
public getInfo ( ) : array
리턴 array

getInfoValueByKey() 공개 메소드

Return single array entry from the array in getInfo() Returns the value of the key if value exists, or null
부터: 2.5.4
public getInfoValueByKey ( $key ) : Mixed
리턴 Mixed

getLogRowDetailsOutput() 공개 메소드

Use this method to output detailed output for a log row Example usage is if a user has uploaded an image then a thumbnail of that image can bo outputed here
public getLogRowDetailsOutput ( object $row ) : string
$row object
리턴 string HTML-formatted output

getLogRowHeaderOutput() 공개 메소드

Returns header output for a log row Format should be common for all log rows and should be like: Username (user role) · Date
public getLogRowHeaderOutput ( $row ) : string
리턴 string HTML

getLogRowPlainTextOutput() 공개 메소드

Defaults to log message with context interpolated. Keep format as plain and simple as possible. Links are ok, for example to link to users or posts. Tags will be stripped when text is used for CSV-exports and so on. Keep it on a single line. No

or
and so on. Example output: Edited post "About the company" Message should sound like it's coming from the user. Image that the name of the user is added in front of the text: Jessie James: Edited post "About the company"

public getLogRowPlainTextOutput ( $row )

getLogRowSenderImageOutput() 공개 메소드

Get output for image Image can be for example gravar if sender is user, or other images if sender i system, wordpress, and so on
public getLogRowSenderImageOutput ( $row )

get_event_ip_number_headers() 공개 메소드

Returns additional headers with ip number from context
부터: 2.0.29
public get_event_ip_number_headers ( $row )

get_ip_number_header_keys() 공개 메소드

Returns array with headers that may contain user IP
부터: 2.0.29

info() 공개 메소드

Example: User logs in, SQL logs.
public info ( string $message, array $context = [] ) : null
$message string
$context array
리턴 null

infoMessage() 공개 메소드

Example: User logs in, SQL logs.
public infoMessage ( string $message, array $context = [] ) : null
$message string key from getInfo messages array
$context array
리턴 null

interpolate() 공개 메소드

Interpolates context values into the message placeholders.
public interpolate ( string $message, array $context = [], array $row = null )
$message string
$context array
$row array Currently not always passed, because loggers need to be updated to support this...

loaded() 공개 메소드

Method that is called automagically when logger is loaded by Simple History Add your init stuff here
public loaded ( )

log() 공개 메소드

Logs with an arbitrary level.
public log ( mixed $level, string $message, array $context = [] ) : null
$level mixed
$message string
$context array
리턴 null

notice() 공개 메소드

Normal but significant events.
public notice ( string $message, array $context = [] ) : null
$message string
$context array
리턴 null

noticeMessage() 공개 메소드

Normal but significant events.
public noticeMessage ( string $message, array $context = [] ) : null
$message string key from getInfo messages array
$context array
리턴 null

validate_ip() 공개 메소드

Ensures an ip address is both a valid IP and does not fall within a private network range.
public validate_ip ( $ip )

warning() 공개 메소드

Example: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.
public warning ( string $message, array $context = [] ) : null
$message string
$context array
리턴 null

warningMessage() 공개 메소드

Exceptional occurrences that are not errors.
public warningMessage ( string $message, array $context = [] ) : null
$message string key from getInfo messages array
$context array
리턴 null

프로퍼티 상세

$lastInsertID 공개적으로 프로퍼티

ID of last inserted row. Used when chaining methods.
public $lastInsertID

$messages 공개적으로 프로퍼티

By adding your messages here they will be stored both translated and non-translated You then log something like this: $this->info( $this->messages["POST_UPDATED"] ); or with the shortcut $this->infoMessage("POST_UPDATED"); which results in the original, untranslated, string being added to the log and database the translated string are then only used when showing the log in the GUI
public $messages

$slug 공개적으로 프로퍼티

Unique slug for this logger Will be saved in DB and used to associate each log row with its logger
public $slug