Class: Agoo::ErrorStream
- Inherits:
-
Object
- Object
- Agoo::ErrorStream
- Defined in:
- ext/agoo/error_stream.c,
ext/agoo/error_stream.c
Overview
Used in a reqquest as the rack.errors attribute. Writing to the stream and flushing will make an error log entry.
Instance Method Summary collapse
-
#flush ⇒ Object
call-seq: flush().
-
#puts(str) ⇒ Object
call-seq: puts(str).
-
#write(str) ⇒ Object
call-seq: write(str).
Instance Method Details
#flush ⇒ Object
call-seq: flush()
Flushs the accumulated text in the stream as an error log entry.
74 75 76 77 78 79 80 81 82 |
# File 'ext/agoo/error_stream.c', line 74
static VALUE
es_flush(VALUE self) {
ErrorStream es = (ErrorStream)DATA_PTR(self);
log_cat(&error_cat, "%s", es->text->text);
es->text->len = 0;
return self;
}
|
#puts(str) ⇒ Object
call-seq: puts(str)
Write the str to the stream along with a newline character, accumulating it until flush is called.
42 43 44 45 46 47 48 49 50 |
# File 'ext/agoo/error_stream.c', line 42
static VALUE
es_puts(VALUE self, VALUE str) {
ErrorStream es = (ErrorStream)DATA_PTR(self);
es->text = text_append(es->text, StringValuePtr(str), (int)RSTRING_LEN(str));
es->text = text_append(es->text, "\n", 1);
return Qnil;
}
|
#write(str) ⇒ Object
call-seq: write(str)
Write the str to the stream, accumulating it until flush is called.
58 59 60 61 62 63 64 65 66 |
# File 'ext/agoo/error_stream.c', line 58
static VALUE
es_write(VALUE self, VALUE str) {
ErrorStream es = (ErrorStream)DATA_PTR(self);
int cnt = (int)RSTRING_LEN(str);
es->text = text_append(es->text, StringValuePtr(str), cnt);
return INT2NUM(cnt);
}
|