Skip to content
y-lohse edited this page Dec 27, 2012 · 4 revisions

Cannon.Logger is a log system, similar to what console.log offers. It is sued internally by the framework to provide informations about everything that is happening, but it can also be easily used by anyone.

Properties

logstack:Array

Array that contains ll the logs, stored as objects. Each log object contains the following properties :

  • message
  • level
  • date
  • caller

Info:String

Constant for the log level Info.

Warning:String

Constant for the log level Warning.

Error:String

Constant for the log level Error.

maxlog:Integer

Maximum number of logs to be displayed when autologing is turned on. Default is 10.

autologing:Boolean

Turns autologing on or off.

autologElement

The element to witch the logs are appended when autologing is on.

Functions

log:Void

Parameter

  • message:String
  • level:String : optionnal, default to Cannon.Logger.Info.

Description

Adds a message to the log. The optional level parameter can be Cannon.Logger.Info, Cannon.Logger.Warning or Cannon.Logger.Error.

logToString:String

Parameter

  • log:Object

Description

Turns a log object into a string.

logToHTML:String

Parameter

  • log:Object

Description

Turns a log object into a bit of HTML.

toHTML:String

Description

Turns the whole logs into HTML.

autolog

Parameters

  • element:DOMElement

Description

Calling this function will active the autologing process. The element passed as parameter will see it's content updated with the logs already in the logstack, and any further logs will be appended to it.

In order not to slow the page down with too much content in the DOM, only the last few logs will be displayed. How many exactly is controlled by the maxlog property.

TO turn autologing off after it has been started, set the autologing property to false.