= Leña {
}[http://travis-ci.org/wbyoung/lena] {
}[https://codeclimate.com/github/wbyoung/lena] {
}[https://coveralls.io/r/wbyoung/lena]
Leña provides simple server-side JavaScript error logging for production Rails applications. This allows you to better track errors that occur in your front-end code.
== Installation
Add the following to your +application.js+:
//= require lena
Add the following to your +routes.rb+:
mount Lena::Engine => "/lena"
Update your +application.html.erb+:
<%= javascript_include_tag "application", lena.configuration %>
If you use Turbolinks or provide other options for your javascript include, you can merge them: lena.configuration.merge("data-something" => true).
== Usage Client Side
Leña will now track all exceptions that are thrown in your application. You can also use Leña to log individual errors without throwing an exception. In your JavaScript, simply:
lena.log('My Error Message')
== Usage Server Side
Leña will simply throw an exception, Lena::JavaScriptError, when it receives a log message. Why? Because you should be using {something}[https://github.com/smartinez87/exception_notification] to report server errors when they occur. Also that's basically what's happening on the client side, so why not throw an exception on the server?
If you need to configure what Leña does, you can add +config/initializers/lena.rb+:
Lena.setup do |config|
config.javascript_handler = Proc.new do |params|
# Custom handling of log message here
end
end
== Alternative Setup
An alternative to setting up Leña on your +application.js+ file is to import Leña separately. This may impact performance, but it will catch compiler errors in any scripts included after it:
<%= javascript_include_tag "lena", lena.configuration %>
== License
This project is distributed under the MIT-LICENSE.