Backbone logger adds some built-in logging to backbone for debugging purposes.
It is meant to be used only in development in order to avoid the pollution of the source code
with MyCustomLogger.log
calls.
It logs to the console the "name" of the current executed function (e.g TodoView#addTodo
) along with the value of this
and the arguments
passed to the function.
Include the script after backbone.
<script src="backbone.js"></script>
<script src="backbone-logger.js"></script>
Backbone logger requires your app to be namespaced under an object. e.g.
var App = {};
App.Todo = Backbone.Model.extend({ ...
After you have included everything and before you start instantiating Backbone objects include this line to enable Logger.
new Backbone.Logger(App).enable();
In the repository you will find the classic TODO example from addyosmani/todomvc with the Backbone Logger enabled.
The following is a sample of the console output. Of course you can inspect the objects in the console.
AppView#addAll d [d, Object
AppView#createOnEnter d [f.Event]
AppView#newAttributes d []
AppView#addOne d [d, d, Object]
TodoView#toggleVisible d []
TodoView#isHidden d []
AppView#statsTemplate d [Object]
TodoView#togglecompleted d [f.Event]
Todo#toggle d []
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request