Permalink
Browse files

Switched to a Coffee based implementation

  • Loading branch information...
1 parent 8d9aed0 commit f8c8dc0740026da81cfb3263ee2ce7ab757ad18b @elthariel elthariel committed Oct 26, 2013
@@ -1,34 +0,0 @@
-(function( jsLogger, $, undefined ) {
- //Public Method
- jsLogger.debug = function(message) {
- invoke('debug', message);
- };
-
- jsLogger.info = function(message) {
- invoke('info', message);
- };
-
- jsLogger.warn = function(message) {
- invoke('warn', message);
- };
-
- jsLogger.error = function(message) {
- invoke('error', message);
- };
-
- jsLogger.fatal = function(message) {
- invoke('fatal', message);
- };
-
-
- //Private Method
- function invoke(level, message) {
- $.ajax({
- type: 'post',
- beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
- data: {level: level, message: message},
- complete: function(request){},
- url: "/logger/rails_client_logger/log"
- })
- }
-}( window.jsLogger = window.jsLogger || {}, jQuery ));
@@ -0,0 +1,15 @@
+window.jsLogger =
+ invoke: (level, message) ->
+ jQuery.ajax {
+ type: 'post'
+ beforeSend: (xhr) ->
+ xhr.setRequestHeader('X-CSRF-Token', jQuery('meta[name="csrf-token"]').attr('content'))
+ data: {level: level, message: message}
+ complete: (request) ->
+ # Nothing yet
+ url: "/logger/rails_client_logger/log"
+ }
+
+for level in ['debug', 'info', 'warn', 'error', 'fatal']
+ jsLogger[level] = (msg) ->
+ jsLogger.invoke(level, msg)

0 comments on commit f8c8dc0

Please sign in to comment.