Javascript Engine
(→Properties) |
(→Methods) |
||
Line 12: | Line 12: | ||
// Output: "1 1 test" | // Output: "1 1 test" | ||
− | * '''debug()''' | + | * '''debug([level, ][value1 [, value2 [, ...]]])''' |
− | * '''alarm()''' | + | Put a debug message in console / log.<br> |
+ | Concatenate values. Put a space between them.<br> | ||
+ | Does nothing if the resulting string is empty.<br> | ||
+ | Debug level is handled if the first parameter is an integer value. Defaults to Engine.DebugNote otherwise.<br> | ||
+ | // The following calls will produce the same debug message: | ||
+ | Engine.debug(Engine.DebugNote,"test","out"); | ||
+ | Engine.debug(8,"test out"); | ||
+ | Engine.debug("test" + " out"); | ||
+ | |||
+ | * '''alarm([info, ]level, value1 [, value2 [, ...]])''' | ||
+ | Put a debug message. Emits an alarm if a callback is installed.<br> | ||
+ | Concatenate values. Put a space between them.<br> | ||
+ | Does nothing if the resulting string is empty.<br> | ||
+ | Parameters:<br> | ||
+ | '''info''': Optional alarm extra information<br> | ||
+ | '''level''': Debug/Alarm level<br> | ||
+ | Engine.alarm("myscript",Engine.DebugWarn,"Some warning"); | ||
+ | // Run time error: | ||
+ | Engine.alarm("some text"); | ||
+ | Engine.alarm("myscript",Engine.DebugWarn); | ||
+ | // No alarm, no debug message: | ||
+ | Engine.alarm("myscript",Engine.DebugWarn,""); | ||
+ | |||
* '''sleep()''' | * '''sleep()''' | ||
* '''usleep()''' | * '''usleep()''' | ||
Line 23: | Line 45: | ||
* '''dump_t()''' | * '''dump_t()''' | ||
* '''print_t()''' | * '''print_t()''' | ||
− | * '''debugName()''' | + | * '''debugName([name])''' |
− | * '''debugLevel()''' | + | Set the debug name.<br> |
− | * '''debugEnabled()''' | + | Retrieve debug name if no parameter is given.<br> |
− | * '''debugAt()''' | + | Parameters:<br> |
− | * '''setDebug()''' | + | '''name''': Debug name to set<br> |
+ | |||
+ | * '''debugLevel([level])''' | ||
+ | Set the debug level.<br> | ||
+ | Retrieve the debug level if no parameter is given.<br> | ||
+ | Parameters:<br> | ||
+ | '''level''': Debug level to set. Ignored if not an integer value<br> | ||
+ | |||
+ | * '''debugEnabled([on])''' | ||
+ | Toggle (set) the debug enabled flag.<br> | ||
+ | Retrieve the debug enabled flag if no parameter is given.<br> | ||
+ | Parameters:<br> | ||
+ | '''on''': TRUE to enable debug output, FALSE to disable it<br> | ||
+ | |||
+ | * '''debugAt(level)''' | ||
+ | Check if the current debug level is greater or equal to requested level.<br> | ||
+ | Parameters:<br> | ||
+ | '''level''': Integer value to check<br> | ||
+ | Return:<br> | ||
+ | TRUE if the current debug level greater than or equal to '''level''', FALSE otherwise.<br> | ||
+ | |||
+ | * '''setDebug(command)''' | ||
+ | Set debug according to command values.<br> | ||
+ | Handled commands:<br> | ||
+ | - '''level <level>''': Set debug level to requested level<br> | ||
+ | - '''reset''': Reset debug level to javascript module debug level<br> | ||
+ | - '''engine''': Reset debug level and debug enabled flag to yate engine settings<br> | ||
+ | - boolean: Set debug enabled flag<br> | ||
+ | All other values are ignored.<br> | ||
+ | |||
* '''started()''' | * '''started()''' | ||
* '''runParams()''' | * '''runParams()''' |
Revision as of 17:23, 7 March 2016
Javascript static Engine object.
This object is frozen.
Methods
- output([value1 [, value2 [, ...]]])
Output data to console / log.
Concatenate parameters. Put a space between them.
Does nothing if the resulting string is empty.
Engine.output("1",1,"test"); Engine.output("1" + " " + 1 + " test"); // Output: "1 1 test"
- debug([level, ][value1 [, value2 [, ...]]])
Put a debug message in console / log.
Concatenate values. Put a space between them.
Does nothing if the resulting string is empty.
Debug level is handled if the first parameter is an integer value. Defaults to Engine.DebugNote otherwise.
// The following calls will produce the same debug message: Engine.debug(Engine.DebugNote,"test","out"); Engine.debug(8,"test out"); Engine.debug("test" + " out");
- alarm([info, ]level, value1 [, value2 [, ...]])
Put a debug message. Emits an alarm if a callback is installed.
Concatenate values. Put a space between them.
Does nothing if the resulting string is empty.
Parameters:
info: Optional alarm extra information
level: Debug/Alarm level
Engine.alarm("myscript",Engine.DebugWarn,"Some warning"); // Run time error: Engine.alarm("some text"); Engine.alarm("myscript",Engine.DebugWarn); // No alarm, no debug message: Engine.alarm("myscript",Engine.DebugWarn,"");
- sleep()
- usleep()
- yield()
- idle()
- restart()
- dump_r()
- print_r()
- dump_t()
- print_t()
- debugName([name])
Set the debug name.
Retrieve debug name if no parameter is given.
Parameters:
name: Debug name to set
- debugLevel([level])
Set the debug level.
Retrieve the debug level if no parameter is given.
Parameters:
level: Debug level to set. Ignored if not an integer value
- debugEnabled([on])
Toggle (set) the debug enabled flag.
Retrieve the debug enabled flag if no parameter is given.
Parameters:
on: TRUE to enable debug output, FALSE to disable it
- debugAt(level)
Check if the current debug level is greater or equal to requested level.
Parameters:
level: Integer value to check
Return:
TRUE if the current debug level greater than or equal to level, FALSE otherwise.
- setDebug(command)
Set debug according to command values.
Handled commands:
- level <level>: Set debug level to requested level
- reset: Reset debug level to javascript module debug level
- engine: Reset debug level and debug enabled flag to yate engine settings
- boolean: Set debug enabled flag
All other values are ignored.
- started()
- runParams()
- configFile()
- setInterval()
- clearInterval()
- setTimeout()
- clearTimeout()
- loadLibrary()
- loadObject()
- replaceParams()
- atob
Decode Base64 data.
Parameters:
b64_str: Mandatory, Base64 encoded data
Return:
Decoded data, boolean false on failure (invalid Base64 data)
str = Engine.atob(b64_str)
- btoa
Encode string data to Base64.
Parameters:
str: Mandatory, data to encode
line_len: Optional line length (split encoded data, add end of line after each line_len chars)
add_eol: Optional, add an extra end of line after encoded data
Return:
Base64 encoded data
b64_str = Engine.btoa(str[,line_len[,add_eol]])
- atoh
Decode Base64 data.
Parameters:
b64_str: Mandatory, Base64 encoded data
hex_sep: Optional separator to use between octets. Set it to 'undefined' if not used and hex_upcase is given
hex_upcase: Optional, use upper case characters in hexa
Return:
Hexified string, boolean false on failure (invalid Base64 data)
hex_str = Engine.atoh(b64_str[,hex_sep[,hex_upcase]])
- htoa
Encode hexified binary (string) data to Base64.
Parameters:
hex_str: Mandatory, data to encode
line_len: Optional line length (split encoded data, add end of line after each line_len chars)
add_eol: Optional, add an extra end of line after encoded data
Return:
The string, boolean false on failure (invalid input string).
b64_str = Engine.htob(hex_str[,line_len[,add_eol]])
- btoh
Convert binary (string) data to hexified string.
Parameters:
str: Mandatory, data to hexify
hex_sep: Optional separator to use between octets. Set it to 'undefined' if not used and hex_upcase is given
hex_upcase: Optional, use upper case characters in hexa
Return:
Hexified string
hex_str = Engine.btoh(str[,hex_sep[,hex_upcase]])
- htob
Unhexify binary (string) data.
Parameters:
hex_str: Mandatory, data to unhexify
hex_sep: Optional separator between octets. Set it to 'undefined' if missing or unknown (autodetect)
Return:
The string, boolean false on failure (invalid input string).
str = Engine.htob(hex_str[,hex_sep])
Properties
- DebugFail, DebugTest, DebugGoOn, DebugConf, DebugStub, DebugWarn, DebugMild, DebugCall, DebugNote, DebugInfo, DebugAll
Debug levels to be used when calling Engine.debug() or Engine.alarm().
NOTE:: Debug level is clamped to interval [DebugTest .. DebugAll] unless 'allow_abort' is enabled in javascript.conf (in this case the debug level is clamped to interval [DebugFail .. DebugAll].
- shared
Provides access to Shared object.
- name
Script name. It may not be available.
This is the name assigned to the script.
This property is missing when running javascript eval command.
Example:
javascript.conf: [scripts] test=some_script.js in some_script.js Engine.name property value is "test"