承接 volnix/jobber 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

volnix/jobber

最新稳定版本:1.4.2

Composer 安装命令:

composer require volnix/jobber

包简介

A slim library for printing typical CLI job output.

README 文档

README

Build Status Downloads Latest Stable Version Code Coverage

Jobber is a super-slim library for printing output from a CLI job. It supports command-line colors through the use of kevinlebrun/colors.php, a well-revered CLI color library.

It was built with simplicity in mind, as printing job output should be the least of your worries when building CLI-based scripts.

Example output from Jobber

***************************************************
2015-01-23 15:52:35 - Starting test_name

INFO: 2015-01-23 15:52:35 - foo
WARNING: 2015-01-23 15:52:35 - bar
SUCCESS: 2015-01-23 15:52:35 - baz
ERROR: 2015-01-23 15:52:35 - qux

2015-01-23 15:52:35 - Execution Time: 0.0 seconds / Peak memory usage: 3.22 Mb
***************************************************

Installation

Command line:

composer require volnix/jobber:~1.0

composer.json:

{
    "name": "your/application",
    "require": {
        "volnix/jobber": "~1.0"
    }
}

Usage

Typically the printer (Volnix/Jobber/Printer) will be started, then stopped. The start method prints out the job name and and some asterisks to fence off this job's output. The stop method prints memory usage, runtime, and more fences.

use Volnix/Jobber/Printer;

Printer::start('my_job_name');
Printer::info('Something happened, but it is not super important.');
Printer::stop();

Jobber also supports getting the output out of the printer in plain-text. This is especially useful for logging job output somewhere.

Printer::start('my_job_name');
Printer::info('Something happened, but it is not super important.');
Printer::stop();

$my_logger->info(Printer::getOutput());

All message types:

  • Info (Printer::info())
  • Warning (Printer::warning())
  • Success (Printer::success())
  • Error (Printer::error())
  • Fatal (Printer::fatal())
    • Note: fatal is merely an alias for error and stop in one call

If you desire to toggle verbosity on your job, this is supported. This will only disable info messages, while still allowing others to come through.

// turn off verbosity, disabling info messages
Printer::setVerbosity(false);

Note: info messages will still be returned when calling Printer::getOutput() for logging purposes

If you desire to run multiple job "sessions" in one command, you can reset the printer.

// do job 1
Printer::start('job_number_1');
// do something in your code...
Printer::success('Something good happened.');
Printer::stop();

// reset the printer
Printer::reset();

// start job 2
Printer::start('job_number_2');
// ...

Finally, you may use sprintf-style messages as well by passing a tokenized (%s, %d, etc.) string as your first argument and an array of tokens as your second.

// printing with tokens
Printer::start('something job');
Printer::info('Exported %d records to %s.', [10, '/filepath/something/here.txt']); // "Exported 10 records to /filepath/something/here.txt"

统计信息

  • 总下载量: 1.38k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-01-26