Logger
in package
Table of Contents
Constants
- LOAD_RETRY_INTERVAL = 20000
- 進捗ファイル読み込みリトライの待機時間(マイクロ秒)
- MAX_LOAD_ATTEMPTS = 3
- 進捗ファイル読み込みの最大試行回数(書き込み中の競合対策)
Properties
- $destinationPath : string
- $json : stdClass
Methods
- __construct() : mixed
- Logger constructor.
- addMessage() : mixed
- メッセージを追加
- addPercentage() : mixed
- error() : mixed
- エラー処理
- getDestinationPath() : string
- Getter $destinationPath
- getJson() : stdClass|null
- Get json object
- init() : mixed
- 初期化
- load() : mixed
- ファイルからロード
- success() : mixed
- 成功時
- terminate() : mixed
- 終了処理
- build() : mixed
- JSON出力
- readJson() : stdClass|null
- 進捗ファイルを読み込み、JSON をデコードして返す。
Constants
LOAD_RETRY_INTERVAL
進捗ファイル読み込みリトライの待機時間(マイクロ秒)
private
mixed
LOAD_RETRY_INTERVAL
= 20000
MAX_LOAD_ATTEMPTS
進捗ファイル読み込みの最大試行回数(書き込み中の競合対策)
private
mixed
MAX_LOAD_ATTEMPTS
= 3
Properties
$destinationPath
protected
string
$destinationPath
= ''
$json
protected
stdClass
$json
Methods
__construct()
Logger constructor.
public
__construct(string $path) : mixed
Parameters
- $path : string
addMessage()
メッセージを追加
public
addMessage(string $message[, int $percentage = 0 ][, int $status = 1 ]) : mixed
Parameters
- $message : string
- $percentage : int = 0
- $status : int = 1
addPercentage()
public
addPercentage([mixed $percentage = 0 ]) : mixed
Parameters
- $percentage : mixed = 0
error()
エラー処理
public
error(mixed $message) : mixed
Parameters
- $message : mixed
getDestinationPath()
Getter $destinationPath
public
getDestinationPath() : string
Return values
stringgetJson()
Get json object
public
getJson() : stdClass|null
Return values
stdClass|nullinit()
初期化
public
init() : mixed
load()
ファイルからロード
public
load() : mixed
success()
成功時
public
success() : mixed
terminate()
終了処理
public
terminate() : mixed
build()
JSON出力
protected
build() : mixed
readJson()
進捗ファイルを読み込み、JSON をデコードして返す。
private
readJson() : stdClass|null
バックアップ処理(別リクエスト)が進捗ファイルを書き込んでいる最中に読み込むと、 truncate 直後の空ファイルや不完全な JSON を読み、json_decode が null を返すことがある。 その場合は短時間待って数回リトライし、書き込み完了後の内容を取得する。 ファイルが存在しない(処理未開始・完了後の削除)場合は null を返す。