kernel

corneliu edited this page Jul 22, 2013 · 18 revisions

The kernel object is referenced in all other objects and can be accessed via this.kernel. It is the main context of the application, all links are attached to it, it acts as emitter and listener and its methods are the base of the application.

utility

this.kernel.utility . time ( date : date|string|number ) : number

returns unixtime (current unixtime if no param)

this.kernel.utility . microtime ( date : date|string|number ) : number

returns microtime (current microtime if no param)

this.kernel.utility . date ( date : date|string|number , mask : string ) : string

returns a date string formatted by a mask

this.kernel.utility . ansi ( colour : string , message : string ) : string

include

this.kernel . include ( path : string ) : object

Tries to include the file located at path. The included class gets overloaded and the .new and .singleton methods are attached. These methods make sure that there is a consistency in creating objects, all have the main objects (kernel and instance) and singletons get stored in the appropriate context.

this.kernel.include(path) . new ( param1 , param2 , [...] ) : object

The included class will be returned as a new object every time.

this.kernel.include(path) . singleton (key, param1, param2, [...]) : object

The included class will be created once and then returned from the context's buffer.

status

this.kernel .status ( ) : object

Gathers status objects from all attached links and the kernel, merges the results and returns.

shutdown

this.kernel . shutdown ( message : string ) : null

Graceful shutdown. All loaded links get their .unload methods called. When all signal that they've shut down the application will exit.

logging

this.kernel . log ( message : string|Error , file : string , date : string|Date|number ) : null

Logs a message to the specified file (if no file present, logs to the default for the current context)

this.kernel . error ( error : string|Error ) : null

Logs an error message (and a trace) to the default error log (for the current context)

this.kernel . fatal ( error : string|Error ) : null

Logs an error message and initiates a shutdown