Phaser
is a npm Module which allows you to create a log of all the actions you want.
You can create some phases wtih an header title, which can cointain some subphases and tasks.
It allows you to create an error messagge if the task's promise is rejected;
A warning messagge or a complete messagge in case of success.
Go ahead to see the fully documentation.
This is the class Phaser
takes to create a Task.
It has a constructor function and some other Method.
The constructor is called with 3 parameters. Usually you can set only the first two.
When you set the Function action, the task wait the return state to continue the Log.
name
- type:
string
- description: The name you want to assign at the Task
- type:
action
- type:
Function
- description: It is the function you want to execute and log its result. It can be a Promise or a normal function.
- type:
If a Task is returned with the complete()
Method it means that it is successfully completed.
You can pass as result
parameter the result of the action.
This Method sets the status as 'Complete' and change the icon with the 'completed icon'.
result
- type:
any
- description: You can pass as result the returned value of the action Function from the task constructor.
- type:
If a Task is returned with the error()
Method it means that an error is occurred.
You can pass as parameter a string to describe the Error.
err
- type:
String
- description: This string is displayed in the Log as a description of the Error
- default:
Generic Error
- type:
If a Task is returned with the warning()
Method it means that a warning is occurred.
The Task is still successfully completed but a warning is displayed.
warn
- type:
Boolean
- description: If it's 'true' the warning is saved in the tasks Array.
- type:
If a Task is returned with the fatal()
Method it means that a fatal error is occurred.
You can pass as parameter a string to describe the Error.
err
- type:
String
- description: This string is displayed in the Log as a description of the Error
- default:
Generic Error
- type:
This Method return a set of utility to change the counter. That counter will be
returned while generating the status. It can be Incremented or Decremented.
name
- type:
String
- description: The Name of the counter
- type:
initial
- type:
Number
- description: The initial value of the Counter. By default it is zero
- default:
0
- type:
state
- type:
String
- description: The state of the Counter. It can be 'normal', 'warning' or 'error'
- default:
normal
- type:
In This section are contained all the Methods Phaser
has got.
It uses Task and Writer to create a log in the console, but he has got
many other usefull Methods.
The constructor creates a new Phaser
object.
description
- type:
String
- description: The title of the new Phase
- type:
options
- type:
Object
- description: Some options for the Phase
autoStart
- type:
Boolean
- description: If it is 'true' the Phase will start automatically, otherwise it requires to call the
start()
Method - default:
false
- type:
- type:
parent
- type:
Class
- description: The Phase class to attach the new Phase
- type:
This Method return a new Phaser Object attached to the main Phase parent
and called with the correct parameter. This will be a subPhase.
description
- type:
String
- description: The description of the new Phase
- type:
options
- type:
Object
- description: Some options for the Phase
- type:
This Method return a new Task
Object, called with the correct parameters return
a new task in the final log.
name
- type:
string
- description: The name of the Task
- type:
exec
- type:
Function
- description: This is the Promise Function; the Task will return the result of this Promise Function.
task
- type:
Class
- description: The task to append to
- default:
this.task
- type:
phaser
- type:
Class
- description: The Phaser which is the parent of the Task
- default:
this.phaser
- type:
- type:
options
- type:
Object
- description: Some options for the new Task
silent
- type:
Boolean
- description: If it is setted as 'true', it will does not show the start or end message in the log
- type:
- type:
This Method is required, at the end of the code, to start the Phase. You can put it after all the code which generate the Log. It does not require any parameters.
// All the code to generate the Log
myPhase.start(); // It will start the Phase called 'myPhase'
This Method return a Phaser error, which is different by the Task.error()
.
After you call the error Method it will stop all the Tasks, it will clear the queue and it will render the error.
If the error is not 'fatal' it will write the error message and continue to other Phase, otherwise it will stop all the Phase.
This Method expects all tasks in the Phase to be resolved before generating the Log. It is usually called with the start()
Method.
// All the code to generate the Log
myPhase.start().waitAllTask(); // It will wait the resolution of all the Tasks
This Module is used by Phaser()
and Task()
to write all the information in the console. It contains the class Writer
and some Methods for any type of message you need to print in the console.
The constructor sets the correct options to use all the Methods.
generation
- type:
Number
- description: It will build a new Writer using the generation index
- default:
0
- type:
transporter
- type:
Function
- description: The writer to use
- default:
Writer.writer
- type:
This Method write a formatted message, using Writer transportee options
message
- type:
String
- description: The message to display
- type:
options
- type:
Object
- description: The options transporter for the writer
- default:
IWriterOptions
- type:
This Method return an header content. If it is the first generation, the header
will be full size and styled, else the writer will build a new header taking a subheader.
content
- type:
String
- description: The name of the Header
- type:
subheader
- type:
String
- description: The Subheader to attached to
- type:
This Method return a footer content. If it is the first generation, the footer
will be styled, else the writer will create a new footer.
content
- type:
String
- description: The content of the footer
- type:
description
- type:
String
- description: The description of the footer
- type:
This Method return the log message you want to write in the console.
Below are all the types of Message you can print in the console.
They all requires the String message and an options parameter which, by default, is the writer options Object, it contains color
and icon
params.
info
- type:
Function
- description: This Function return an Info Message in the console.
message
- type:
String
- description: The message you want to write
- type:
options
- type:
Object
- description: The color and icon options for the message
- default:
IWriterOptions
- type:
- type:
success
- type:
Function
- description: This Function return a Success Message in the console.
message
- type:
String
- description: The message you want to write
- type:
options
- type:
Object
- description: The color and icon options for the message
- default:
IWriterOptions
- type:
- type:
warning
- type:
Function
- description: This Function return a Warning Message in the console.
message
- type:
String
- description: The message you want to write
- type:
options
- type:
Object
- description: The color and icon options for the message
- default:
IWriterOptions
- type:
- type:
error
- type:
Function
- description: This Function return an Error Message in the console.
message
- type:
String
- description: The message you want to write
- type:
options
- type:
Object
- description: The color and icon options for the message
- default:
IWriterOptions
- type:
- type:
fatal
- type:
Function
- description: This Function return a Fatal Error Message in the console.
message
- type:
String
- description: The message you want to write
- type:
options
- type:
Object
- description: The color and icon options for the message
- default:
IWriterOptions
- type:
- type:
running
- type:
Function
- description: This Function return a Running Message in the console.
message
- type:
String
- description: The message you want to write
- type:
options
- type:
Object
- description: The color and icon options for the message
- default:
IWriterOptions
- type:
- type: