Class: String

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#scan_apache_logsObject

Scans self, which is expected to be a single line from an Apache error or access log, and returns a Hash of the components of the log message. The following parts of the log message are returned if they are present: IPv4 address, datetime, HTTP Version used, the browser string given by the client, any absolute or relative URLs, the error level, HTTP response code, HTTP Method (verb), and any other uncategorized strings present.



9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
# File 'ext/scan_apache_logs/scan_apache_logs.yy.c', line 9265

VALUE t_scan_apache_logs(VALUE self) {
  KVPAIR kv_result;
  int scan_complete = 0;
  int building_words_to_string = 0;
  VALUE token_hash = rb_hash_new();
  
  BEGIN(INITIAL);
  
  /* error out on absurdly large strings */
  raise_error_for_string_too_long(self);
  /* {:message => self()} */
  include_message_in_token_hash(self, token_hash);
  /* {:id => UUID} */
  add_uuid_to_token_hash(token_hash);
  apache_logs_yy_scan_string(RSTRING_PTR(self));
  while (scan_complete == 0) {
    kv_result = scan_apache_logs();
    if (kv_result.key == "EOF"){
      scan_complete = 1;
    }
    else if (kv_result.key == "strings"){
      /* build a string until we get a non-word */
      if (building_words_to_string == 0){
        building_words_to_string = 1;
        push_kv_pair_to_hash(kv_result, token_hash);
      }
      else{
        concat_word_to_string(kv_result, token_hash);
      }    
    }    
    else {
      building_words_to_string = 0;
      push_kv_pair_to_hash(kv_result, token_hash);
    }
  }
  apache_logs_yy_delete_buffer(YY_CURRENT_BUFFER);
  return rb_obj_dup(token_hash);
}

#scan_rails_logsObject

Scans self, which is expected to be a line from a Rails production or dev log, and returns a Hash of the significant features in the log message, including the IP address of the client, the Controller and Action, any partials rendered, and the time spent rendering them, the duration of the DB request(s), the HTTP verb, etc.



11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
# File 'ext/scan_rails_logs/scan_rails_logs.yy.c', line 11448

VALUE t_scan_rails_logs(VALUE self) {
  KVPAIR kv_result;
  int scan_complete = 0;
  int building_words_to_string = 0;
  VALUE token_hash = rb_hash_new();
  
  BEGIN(INITIAL);
  
  /* error out on absurdly large strings */
  raise_error_for_string_too_long(self);
  /* {:message => self()} */
  include_message_in_token_hash(self, token_hash);
  /* {:id => UUID} */
  add_uuid_to_token_hash(token_hash);
  rails_logs_yy_scan_string(RSTRING_PTR(self));
  while (scan_complete == 0) {
    kv_result = scan_rails_logs();
    if (kv_result.key == "EOF"){
      scan_complete = 1;
    }
    else if (kv_result.key == "strings"){
      /* build a string until we get a non-word */
      if (building_words_to_string == 0){
        building_words_to_string = 1;
        push_kv_pair_to_hash(kv_result, token_hash);
      }
      else{
        concat_word_to_string(kv_result, token_hash);
      }    
    }    
    else {
      building_words_to_string = 0;
      push_kv_pair_to_hash(kv_result, token_hash);
    }
  }
  rails_logs_yy_delete_buffer(YY_CURRENT_BUFFER);
  return rb_obj_dup(token_hash);
}