jFactory > Reference > Traits > TraitLog
TraitLog
Attachs a configurable console logger to the component, using JFactoryLogger
.
- The logs are automatically labeled with the value of
myComponent.$.about.name
- The logger can be enabled or disabled at runtime.
Although it is not directly supported by TraitLog, a JFactoryLogger
can also:
- Create children that can be disabled by inheritance.
- Filter by label and methods (log, warn, error).
Inherited config
By default, for all components, logs are :
- disabled when using the production distribution of jFactory.
- enabled when using the development distribution of jFactory.
[//]: # (TODO This behavior can be changed by setting jFactoryConfig.TraitLog.enabled = true | false) |
Component config
myComponent.$.logger.enable()
myComponent.$.logger.disable()
Injected Methods
$log(obj {*} [, ...obj {*}])
$logWarn(obj {*} [, ...obj {*}])
$logErr(obj {*} [, ...obj {*}])
Usages
myComponent.$log("mouse enter the element", domTarget)
myComponent.$logWarn("request timeout", request)
myComponent.$logErr("error:", errorObject)