PHP Class DataSift\Storyplayer\Output

Inheritance: extends DataSift\Storyplayer\OutputLib\OutputPlugin
Exibir arquivo Open project: datasift/storyplayer Class Usage Examples

Protected Properties

Property Type Description
$activityLog array this is used for producing detailed error reports when something has gone badly wrong
$plugins array a list of the plugins that are currently active

Public Methods

Method Description
__construct ( ) constructor
disableColourSupport ( ) : void disables any colour output
enableColourSupport ( ) : void asks each active plugin to switch on colour support if possible
endPhase ( Phase $phase, Phase_Result $phaseResult ) : void called when a story ends a phase
endPhaseGroup ( PhaseGroup_Result $result ) : void called when we have finished playing a PhaseGroup
endStoryplayer ( float $duration ) : integer called when Storyplayer exits
enforceColourSupport ( ) : void forces switching on colour support
getActiveConsolePlugin ( ) : Console | null return the active plugin in the 'console' slot
getActivePluginInSlot ( string $slotName ) : OutputPlugin | null return the active plugin in the named slot
getPlugins ( ) : array get the array of all plugins
logCliError ( string $msg ) : void called when the outer CLI shell encounters a fatal error
logCliErrorWithException ( string $msg, Exception $e ) : void called when the outer CLI shell encounters a fatal error
logCliInfo ( string $msg ) : void called when the outer CLI shell needs to tell the user something
logCliWarning ( string $msg ) : void called when the outer CLI shell needs to publish a warning
logPhaseActivity ( string $msg, array | null $codeLine = null ) : void called when a story logs an action
logPhaseCodeLine ( array $codeLine ) : void called when we want to record which line of code in a phase is currently executing
logPhaseError ( string $phaseName, string $msg ) : void called when a story logs an error
logPhaseSkipped ( string $phaseName, string $msg ) : void called when a story is skipped
logPhaseSubprocessOutput ( string $msg ) : void called when a story logs the (possibly partial) output from running a subprocess
logVardump ( string $name, mixed $var ) : void an alternative to using PHP's built-in var_dump()
resetSilentMode ( ) : void disable 'silent' mode
setSilentMode ( ) : void switches 'silent' mode on
startPhase ( $phase ) : void called when a story starts a new phase
startPhaseGroup ( string $activity, string $name ) : void called when we start playing a new PhaseGroup
startStoryplayer ( string $version, string $url, string $copyright, string $license ) : void called when storyplayer starts
usePluginAsConsole ( Console $plugin ) : void make a plugin the one that we use when writing to the user's console
usePluginInSlot ( OutputPlugin $plugin, string $slotName ) set the plugin for a named output slot

Method Details

__construct() public method

ensures we have a default console that is connected to stdout
public __construct ( )

disableColourSupport() public method

disables any colour output
public disableColourSupport ( ) : void
return void

enableColourSupport() public method

a plugin may still choose to not output colour. one example of this are consoles. they're happy to output colour if talking to a terminal, but choose not to output colour if they're only writing to log files or to a pipe into another UNIX process.
public enableColourSupport ( ) : void
return void

endPhase() public method

called when a story ends a phase
public endPhase ( Phase $phase, Phase_Result $phaseResult ) : void
$phase DataSift\Storyplayer\Phases\Phase the phase that has finished
$phaseResult DataSift\Storyplayer\PlayerLib\Phase_Result the result of running $phase
return void

endPhaseGroup() public method

NOTE: we cannot use a type-hint for $result here. we may pass in a class that inherits from PhaseGroup_Result, and (annoyingly) this isn't allowed if we use a type-hint (grrrr)
public endPhaseGroup ( PhaseGroup_Result $result ) : void
$result DataSift\Storyplayer\PlayerLib\PhaseGroup_Result
return void

endStoryplayer() public method

called when Storyplayer exits
public endStoryplayer ( float $duration ) : integer
$duration float how long did storyplayer take to run (in seconds)?
return integer

enforceColourSupport() public method

forces switching on colour support
public enforceColourSupport ( ) : void
return void

getActiveConsolePlugin() public method

return the active plugin in the 'console' slot
public getActiveConsolePlugin ( ) : Console | null
return DataSift\Storyplayer\Console\Console | null

getActivePluginInSlot() public method

return the active plugin in the named slot
public getActivePluginInSlot ( string $slotName ) : OutputPlugin | null
$slotName string
return DataSift\Storyplayer\OutputLib\OutputPlugin | null

getPlugins() public method

get the array of all plugins
public getPlugins ( ) : array
return array

logCliError() public method

called when the outer CLI shell encounters a fatal error
public logCliError ( string $msg ) : void
$msg string the error message to show the user
return void

logCliErrorWithException() public method

called when the outer CLI shell encounters a fatal error
public logCliErrorWithException ( string $msg, Exception $e ) : void
$msg string the error message to show the user
$e Exception the exception that caused the error
return void

logCliInfo() public method

called when the outer CLI shell needs to tell the user something
public logCliInfo ( string $msg ) : void
$msg string the message to show the user
return void

logCliWarning() public method

called when the outer CLI shell needs to publish a warning
public logCliWarning ( string $msg ) : void
$msg string the warning message to show the user
return void

logPhaseActivity() public method

called when a story logs an action
public logPhaseActivity ( string $msg, array | null $codeLine = null ) : void
$msg string the message to write to the logs / console
$codeLine array | null information about the line of code that is executing
return void

logPhaseCodeLine() public method

called when we want to record which line of code in a phase is currently executing
public logPhaseCodeLine ( array $codeLine ) : void
$codeLine array details about the line of code that is executing
return void

logPhaseError() public method

called when a story logs an error
public logPhaseError ( string $phaseName, string $msg ) : void
$phaseName string the name of the phase where the error occurred
$msg string an error message to send to console|logfile
return void

logPhaseSkipped() public method

called when a story is skipped
public logPhaseSkipped ( string $phaseName, string $msg ) : void
$phaseName string the name of the phase where the error occurred
$msg string an informational message to send to console|logfile
return void

logPhaseSubprocessOutput() public method

called when a story logs the (possibly partial) output from running a subprocess
public logPhaseSubprocessOutput ( string $msg ) : void
$msg string the output to log
return void

logVardump() public method

an alternative to using PHP's built-in var_dump()
public logVardump ( string $name, mixed $var ) : void
$name string a human-readable name to describe $var
$var mixed the variable to dump
return void

resetSilentMode() public method

NOTE: it is up to each plugin in turn whether or not to support 'silent' mode at all
public resetSilentMode ( ) : void
return void

setSilentMode() public method

in 'silent' mode, we do not write log activity to the output writer at all. HOWEVER, the plugin may still add the log activity to any internal cache it has (can be useful for error reports etc)
public setSilentMode ( ) : void
return void

startPhase() public method

$param Phase $phase the phase that we are executing
public startPhase ( $phase ) : void
return void

startPhaseGroup() public method

called when we start playing a new PhaseGroup
public startPhaseGroup ( string $activity, string $name ) : void
$activity string what are we doing? (e.g. 'creating', 'running')
$name string the name of the phase group
return void

startStoryplayer() public method

called when storyplayer starts
public startStoryplayer ( string $version, string $url, string $copyright, string $license ) : void
$version string
$url string
$copyright string
$license string
return void

usePluginAsConsole() public method

make a plugin the one that we use when writing to the user's console
public usePluginAsConsole ( Console $plugin ) : void
$plugin DataSift\Storyplayer\Console\Console the plugin that we want
return void

usePluginInSlot() public method

set the plugin for a named output slot
public usePluginInSlot ( OutputPlugin $plugin, string $slotName )
$plugin DataSift\Storyplayer\OutputLib\OutputPlugin the plugin to use in the slot
$slotName string the name of the slot to use for this plugin

Property Details

$activityLog protected_oe property

this is used for producing detailed error reports when something has gone badly wrong
protected array $activityLog
return array

$plugins protected_oe property

a list of the plugins that are currently active
protected array $plugins
return array