agoo 2.5.5 → 2.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of agoo might be problematic. Click here for more details.

Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/README.md +1 -1
  4. data/ext/agoo/agoo.c +4 -3
  5. data/ext/agoo/atomic.h +120 -0
  6. data/ext/agoo/bind.c +52 -52
  7. data/ext/agoo/bind.h +13 -13
  8. data/ext/agoo/con.c +499 -481
  9. data/ext/agoo/con.h +47 -39
  10. data/ext/agoo/debug.c +42 -42
  11. data/ext/agoo/debug.h +1 -1
  12. data/ext/agoo/doc.c +17 -17
  13. data/ext/agoo/doc.h +12 -12
  14. data/ext/agoo/err.c +18 -18
  15. data/ext/agoo/err.h +27 -27
  16. data/ext/agoo/error_stream.c +9 -9
  17. data/ext/agoo/extconf.rb +3 -0
  18. data/ext/agoo/gqlintro.c +43 -43
  19. data/ext/agoo/gqlintro.h +1 -1
  20. data/ext/agoo/gqlvalue.c +131 -131
  21. data/ext/agoo/gqlvalue.h +32 -32
  22. data/ext/agoo/graphql.c +158 -158
  23. data/ext/agoo/graphql.h +34 -33
  24. data/ext/agoo/hook.c +15 -14
  25. data/ext/agoo/hook.h +18 -14
  26. data/ext/agoo/http.c +14 -14
  27. data/ext/agoo/http.h +4 -4
  28. data/ext/agoo/kinds.h +5 -5
  29. data/ext/agoo/log.c +232 -224
  30. data/ext/agoo/log.h +93 -93
  31. data/ext/agoo/method.h +17 -17
  32. data/ext/agoo/page.c +88 -86
  33. data/ext/agoo/page.h +21 -21
  34. data/ext/agoo/pub.c +36 -36
  35. data/ext/agoo/pub.h +23 -23
  36. data/ext/agoo/queue.c +37 -38
  37. data/ext/agoo/queue.h +20 -19
  38. data/ext/agoo/rack_logger.c +13 -13
  39. data/ext/agoo/ready.c +357 -0
  40. data/ext/agoo/ready.h +41 -0
  41. data/ext/agoo/req.c +11 -11
  42. data/ext/agoo/req.h +30 -31
  43. data/ext/agoo/request.c +46 -46
  44. data/ext/agoo/request.h +2 -2
  45. data/ext/agoo/res.c +40 -18
  46. data/ext/agoo/res.h +14 -14
  47. data/ext/agoo/response.c +6 -6
  48. data/ext/agoo/response.h +9 -9
  49. data/ext/agoo/rhook.c +3 -3
  50. data/ext/agoo/rhook.h +1 -1
  51. data/ext/agoo/rlog.c +47 -42
  52. data/ext/agoo/rlog.h +0 -1
  53. data/ext/agoo/rresponse.c +33 -33
  54. data/ext/agoo/rresponse.h +1 -1
  55. data/ext/agoo/rserver.c +184 -175
  56. data/ext/agoo/rserver.h +2 -2
  57. data/ext/agoo/rupgraded.c +41 -41
  58. data/ext/agoo/rupgraded.h +3 -3
  59. data/ext/agoo/sdl.c +80 -80
  60. data/ext/agoo/sdl.h +1 -1
  61. data/ext/agoo/seg.h +2 -2
  62. data/ext/agoo/server.c +143 -117
  63. data/ext/agoo/server.h +43 -42
  64. data/ext/agoo/sse.c +7 -7
  65. data/ext/agoo/sse.h +4 -4
  66. data/ext/agoo/subject.c +5 -5
  67. data/ext/agoo/subject.h +6 -6
  68. data/ext/agoo/text.c +21 -21
  69. data/ext/agoo/text.h +14 -13
  70. data/ext/agoo/upgraded.c +41 -40
  71. data/ext/agoo/upgraded.h +41 -40
  72. data/ext/agoo/websocket.c +42 -42
  73. data/ext/agoo/websocket.h +16 -16
  74. data/lib/agoo/version.rb +1 -1
  75. data/test/static_test.rb +2 -0
  76. metadata +5 -5
  77. data/ext/agoo/log_queue.h +0 -30
  78. data/ext/agoo/sub.c +0 -111
  79. data/ext/agoo/sub.h +0 -36
@@ -10,7 +10,7 @@
10
10
  #include "req.h"
11
11
 
12
12
  extern void request_init(VALUE mod);
13
- extern VALUE request_wrap(Req req);
14
- extern VALUE request_env(Req req, VALUE self);
13
+ extern VALUE request_wrap(agooReq req);
14
+ extern VALUE request_env(agooReq req, VALUE self);
15
15
 
16
16
  #endif // AGOO_REQUEST_H
@@ -1,45 +1,67 @@
1
1
  // Copyright (c) 2018, Peter Ohler, All rights reserved.
2
2
 
3
+ #include <stdio.h>
3
4
  #include <stdlib.h>
4
5
 
5
6
  #include "con.h"
6
7
  #include "debug.h"
7
8
  #include "res.h"
8
9
 
9
- Res
10
- res_create(Con con) {
11
- Res res = (Res)malloc(sizeof(struct _Res));
10
+ agooRes
11
+ agoo_res_create(agooCon con) {
12
+ agooRes res = NULL;
12
13
 
13
- if (NULL != res) {
14
+ pthread_mutex_lock(&con->loop->lock);
15
+ if (NULL != (res = con->loop->res_head)) {
16
+ con->loop->res_head = res->next;
17
+ if (NULL == con->loop->res_head) {
18
+ con->loop->res_tail = NULL;
19
+ }
20
+ }
21
+ pthread_mutex_unlock(&con->loop->lock);
22
+
23
+ if (NULL == res) {
24
+ if (NULL == (res = (agooRes)malloc(sizeof(struct _agooRes)))) {
25
+ return NULL;
26
+ }
14
27
  DEBUG_ALLOC(mem_res, res)
15
- res->next = NULL;
16
- atomic_init(&res->message, NULL);
17
- res->con = con;
18
- res->con_kind = CON_HTTP;
19
- res->close = false;
20
- res->ping = false;
21
- res->pong = false;
22
28
  }
29
+ res->next = NULL;
30
+ atomic_init(&res->message, NULL);
31
+ res->con = con;
32
+ res->con_kind = AGOO_CON_HTTP;
33
+ res->close = false;
34
+ res->ping = false;
35
+ res->pong = false;
36
+
23
37
  return res;
24
38
  }
25
39
 
26
40
  void
27
- res_destroy(Res res) {
41
+ agoo_res_destroy(agooRes res) {
28
42
  if (NULL != res) {
29
- Text message = res_message(res);
43
+ agooText message = agoo_res_message(res);
30
44
 
31
45
  if (NULL != message) {
32
- text_release(message);
46
+ agoo_text_release(message);
47
+ }
48
+
49
+ res->next = NULL;
50
+ pthread_mutex_lock(&res->con->loop->lock);
51
+ if (NULL == res->con->loop->res_tail) {
52
+ res->con->loop->res_head = res;
53
+ } else {
54
+ res->con->loop->res_tail->next = res;
33
55
  }
34
- DEBUG_FREE(mem_res, res)
35
- free(res);
56
+ res->con->loop->res_tail = res;
57
+ pthread_mutex_unlock(&res->con->loop->lock);
36
58
  }
37
59
  }
38
60
 
39
61
  void
40
- res_set_message(Res res, Text t) {
62
+ agoo_res_set_message(agooRes res, agooText t) {
41
63
  if (NULL != t) {
42
- text_ref(t);
64
+ agoo_text_ref(t);
43
65
  }
44
66
  atomic_store(&res->message, t);
45
67
  }
@@ -3,30 +3,30 @@
3
3
  #ifndef AGOO_RES_H
4
4
  #define AGOO_RES_H
5
5
 
6
- #include <stdatomic.h>
7
6
  #include <stdbool.h>
8
7
 
9
- #include "text.h"
8
+ #include "atomic.h"
10
9
  #include "con.h"
10
+ #include "text.h"
11
11
 
12
- struct _Con;
12
+ struct _agooCon;
13
13
 
14
- typedef struct _Res {
15
- struct _Res *next;
16
- struct _Con *con;
17
- _Atomic(Text) message;
18
- ConKind con_kind;
14
+ typedef struct _agooRes {
15
+ struct _agooRes *next;
16
+ struct _agooCon *con;
17
+ _Atomic(agooText) message;
18
+ agooConKind con_kind;
19
19
  bool close;
20
20
  bool ping;
21
21
  bool pong;
22
- } *Res;
22
+ } *agooRes;
23
23
 
24
- extern Res res_create(struct _Con *con);
25
- extern void res_destroy(Res res);
26
- extern void res_set_message(Res res, Text t);
24
+ extern agooRes agoo_res_create(struct _agooCon *con);
25
+ extern void agoo_res_destroy(agooRes res);
26
+ extern void agoo_res_set_message(agooRes res, agooText t);
27
27
 
28
- static inline Text
29
- res_message(Res res) {
28
+ static inline agooText
29
+ agoo_res_message(agooRes res) {
30
30
  return atomic_load(&res->message);
31
31
  }
32
32
 
@@ -9,11 +9,11 @@
9
9
  #include "response.h"
10
10
 
11
11
  int
12
- response_len(Response res) {
12
+ agoo_response_len(agooResponse res) {
13
13
  char buf[256];
14
- const char *msg = http_code_message(res->code);
14
+ const char *msg = agoo_http_code_message(res->code);
15
15
  int len = snprintf(buf, sizeof(buf), "HTTP/1.1 %d %s\r\nContent-Length: %d\r\n", res->code, msg, res->blen);
16
- Header h;
16
+ agooHeader h;
17
17
 
18
18
  for (h = res->headers; NULL != h; h = h->next) {
19
19
  len += h->len;
@@ -25,9 +25,9 @@ response_len(Response res) {
25
25
  }
26
26
 
27
27
  void
28
- response_fill(Response res, char *buf) {
29
- Header h;
30
- const char *msg = http_code_message(res->code);
28
+ agoo_response_fill(agooResponse res, char *buf) {
29
+ agooHeader h;
30
+ const char *msg = agoo_http_code_message(res->code);
31
31
 
32
32
  buf += sprintf(buf, "HTTP/1.1 %d %s\r\nContent-Length: %d\r\n", res->code, msg, res->blen);
33
33
 
@@ -3,26 +3,26 @@
3
3
  #ifndef AGOO_RESPONSE_H
4
4
  #define AGOO_RESPONSE_H
5
5
 
6
- #include <stdatomic.h>
7
6
  #include <stdbool.h>
8
7
 
8
+ #include "atomic.h"
9
9
  #include "server.h"
10
10
  #include "text.h"
11
11
 
12
- typedef struct _Header {
13
- struct _Header *next;
12
+ typedef struct _agooHeader {
13
+ struct _agooHeader *next;
14
14
  int len;
15
15
  char text[8];
16
- } *Header;
16
+ } *agooHeader;
17
17
 
18
- typedef struct _Response {
18
+ typedef struct _agooResponse {
19
19
  int code;
20
- Header headers;
20
+ agooHeader headers;
21
21
  int blen;
22
22
  char *body;
23
- } *Response;
23
+ } *agooResponse;
24
24
 
25
- extern int response_len(Response res);
26
- extern void response_fill(Response res, char *buf);
25
+ extern int agoo_response_len(agooResponse res);
26
+ extern void agoo_response_fill(agooResponse res, char *buf);
27
27
 
28
28
  #endif // AGOO_RESPONSE_H
@@ -53,9 +53,9 @@ resolve_classpath(const char *name, size_t len) {
53
53
  return resolve_classname(clas, class_name);
54
54
  }
55
55
 
56
- Hook
57
- rhook_create(Method method, const char *pattern, VALUE handler, Queue q) {
58
- Hook hook = hook_create(method, pattern, NULL, RACK_HOOK, q);
56
+ agooHook
57
+ rhook_create(agooMethod method, const char *pattern, VALUE handler, agooQueue q) {
58
+ agooHook hook = agoo_hook_create(method, pattern, NULL, RACK_HOOK, q);
59
59
 
60
60
  if (NULL != hook) {
61
61
  if (T_STRING == rb_type(handler)) {
@@ -8,7 +8,7 @@
8
8
  #include "hook.h"
9
9
  #include "method.h"
10
10
 
11
- extern Hook rhook_create(Method method, const char *pattern, VALUE handler, Queue q);
11
+ extern agooHook rhook_create(agooMethod method, const char *pattern, VALUE handler, agooQueue q);
12
12
  extern VALUE resolve_classpath(const char *name, size_t len);
13
13
 
14
14
  #endif // AGOO_RHOOK_H
@@ -14,6 +14,7 @@
14
14
 
15
15
  #include "debug.h"
16
16
  #include "dtime.h"
17
+ #include "log.h"
17
18
  #include "rlog.h"
18
19
 
19
20
  static VALUE log_mod = Qundef;
@@ -52,14 +53,14 @@ rlog_configure(VALUE self, VALUE options) {
52
53
 
53
54
  if (Qnil != (v = rb_hash_lookup(options, ID2SYM(rb_intern("dir"))))) {
54
55
  rb_check_type(v, T_STRING);
55
- strncpy(the_log.dir, StringValuePtr(v), sizeof(the_log.dir));
56
- the_log.dir[sizeof(the_log.dir) - 1] = '\0';
56
+ strncpy(agoo_log.dir, StringValuePtr(v), sizeof(agoo_log.dir));
57
+ agoo_log.dir[sizeof(agoo_log.dir) - 1] = '\0';
57
58
  }
58
59
  if (Qnil != (v = rb_hash_lookup(options, ID2SYM(rb_intern("max_files"))))) {
59
60
  int max = FIX2INT(v);
60
61
 
61
62
  if (1 <= max || max < 100) {
62
- the_log.max_files = max;
63
+ agoo_log.max_files = max;
63
64
  } else {
64
65
  rb_raise(rb_eArgError, "max_files must be between 1 and 100.");
65
66
  }
@@ -68,23 +69,23 @@ rlog_configure(VALUE self, VALUE options) {
68
69
  int max = FIX2INT(v);
69
70
 
70
71
  if (1 <= max) {
71
- the_log.max_size = max;
72
+ agoo_log.max_size = max;
72
73
  } else {
73
74
  rb_raise(rb_eArgError, "max_size must be 1 or more.");
74
75
  }
75
76
  }
76
77
  if (Qnil != (v = rb_hash_lookup(options, ID2SYM(rb_intern("console"))))) {
77
- the_log.console = (Qtrue == v);
78
+ agoo_log.console = (Qtrue == v);
78
79
  }
79
80
  if (Qnil != (v = rb_hash_lookup(options, ID2SYM(rb_intern("classic"))))) {
80
- the_log.classic = (Qtrue == v);
81
+ agoo_log.classic = (Qtrue == v);
81
82
  }
82
83
  if (Qnil != (v = rb_hash_lookup(options, ID2SYM(rb_intern("colorize"))))) {
83
- the_log.colorize = (Qtrue == v);
84
+ agoo_log.colorize = (Qtrue == v);
84
85
  }
85
86
  if (Qnil != (v = rb_hash_lookup(options, ID2SYM(rb_intern("states"))))) {
86
87
  if (T_HASH == rb_type(v)) {
87
- LogCat cat = the_log.cats;
88
+ agooLogCat cat = agoo_log.cats;
88
89
  VALUE cv;
89
90
 
90
91
  for (; NULL != cat; cat = cat->next) {
@@ -101,15 +102,15 @@ rlog_configure(VALUE self, VALUE options) {
101
102
  }
102
103
  }
103
104
  }
104
- if (NULL != the_log.file) {
105
- fclose(the_log.file);
106
- the_log.file = NULL;
105
+ if (NULL != agoo_log.file) {
106
+ fclose(agoo_log.file);
107
+ agoo_log.file = NULL;
107
108
  }
108
- if ('\0' != *the_log.dir) {
109
- if (0 != mkdir(the_log.dir, 0770) && EEXIST != errno) {
110
- rb_raise(rb_eIOError, "Failed to create '%s'.", the_log.dir);
109
+ if ('\0' != *agoo_log.dir) {
110
+ if (0 != mkdir(agoo_log.dir, 0770) && EEXIST != errno) {
111
+ rb_raise(rb_eIOError, "Failed to create '%s'.", agoo_log.dir);
111
112
  }
112
- open_log_file();
113
+ agoo_log_open_file();
113
114
  }
114
115
  return Qnil;
115
116
  }
@@ -122,7 +123,7 @@ rlog_configure(VALUE self, VALUE options) {
122
123
  */
123
124
  static VALUE
124
125
  rlog_shutdown(VALUE self) {
125
- log_close();
126
+ agoo_log_close();
126
127
  return Qnil;
127
128
  }
128
129
 
@@ -134,7 +135,7 @@ rlog_shutdown(VALUE self) {
134
135
  */
135
136
  static VALUE
136
137
  rlog_errorp(VALUE self) {
137
- return error_cat.on ? Qtrue : Qfalse;
138
+ return agoo_error_cat.on ? Qtrue : Qfalse;
138
139
  }
139
140
 
140
141
  /* Document-method: warn?
@@ -145,7 +146,7 @@ rlog_errorp(VALUE self) {
145
146
  */
146
147
  static VALUE
147
148
  rlog_warnp(VALUE self) {
148
- return warn_cat.on ? Qtrue : Qfalse;
149
+ return agoo_warn_cat.on ? Qtrue : Qfalse;
149
150
  }
150
151
 
151
152
  /* Document-method: info?
@@ -156,7 +157,7 @@ rlog_warnp(VALUE self) {
156
157
  */
157
158
  static VALUE
158
159
  rlog_infop(VALUE self) {
159
- return info_cat.on ? Qtrue : Qfalse;
160
+ return agoo_info_cat.on ? Qtrue : Qfalse;
160
161
  }
161
162
 
162
163
  /* Document-method: debug?
@@ -167,7 +168,7 @@ rlog_infop(VALUE self) {
167
168
  */
168
169
  static VALUE
169
170
  rlog_debugp(VALUE self) {
170
- return debug_cat.on ? Qtrue : Qfalse;
171
+ return agoo_debug_cat.on ? Qtrue : Qfalse;
171
172
  }
172
173
 
173
174
  /* Document-method: error
@@ -178,7 +179,7 @@ rlog_debugp(VALUE self) {
178
179
  */
179
180
  static VALUE
180
181
  rlog_error(VALUE self, VALUE msg) {
181
- log_cat(&error_cat, "%s", StringValuePtr(msg));
182
+ agoo_log_cat(&agoo_error_cat, "%s", StringValuePtr(msg));
182
183
  return Qnil;
183
184
  }
184
185
 
@@ -190,7 +191,7 @@ rlog_error(VALUE self, VALUE msg) {
190
191
  */
191
192
  static VALUE
192
193
  rlog_warn(VALUE self, VALUE msg) {
193
- log_cat(&warn_cat, "%s", StringValuePtr(msg));
194
+ agoo_log_cat(&agoo_warn_cat, "%s", StringValuePtr(msg));
194
195
  return Qnil;
195
196
  }
196
197
 
@@ -202,7 +203,7 @@ rlog_warn(VALUE self, VALUE msg) {
202
203
  */
203
204
  static VALUE
204
205
  rlog_info(VALUE self, VALUE msg) {
205
- log_cat(&info_cat, "%s", StringValuePtr(msg));
206
+ agoo_log_cat(&agoo_info_cat, "%s", StringValuePtr(msg));
206
207
  return Qnil;
207
208
  }
208
209
 
@@ -214,7 +215,7 @@ rlog_info(VALUE self, VALUE msg) {
214
215
  */
215
216
  static VALUE
216
217
  rlog_debug(VALUE self, VALUE msg) {
217
- log_cat(&debug_cat, "%s", StringValuePtr(msg));
218
+ agoo_log_cat(&agoo_debug_cat, "%s", StringValuePtr(msg));
218
219
  return Qnil;
219
220
  }
220
221
 
@@ -226,7 +227,7 @@ rlog_debug(VALUE self, VALUE msg) {
226
227
  */
227
228
  static VALUE
228
229
  rlog_color_get(VALUE self, VALUE label) {
229
- LogCat cat = log_cat_find(StringValuePtr(label));
230
+ agooLogCat cat = agoo_log_cat_find(StringValuePtr(label));
230
231
 
231
232
  if (NULL == cat) {
232
233
  return Qnil;
@@ -246,8 +247,8 @@ static VALUE
246
247
  rlog_color_set(VALUE self, VALUE label, VALUE color) {
247
248
  const char *label_str = StringValuePtr(label);
248
249
  const char *color_name = StringValuePtr(color);
249
- LogCat cat = log_cat_find(label_str);
250
- Color c = find_color(color_name);
250
+ agooLogCat cat = agoo_log_cat_find(label_str);
251
+ agooColor c = find_color(color_name);
251
252
 
252
253
  if (NULL == cat) {
253
254
  rb_raise(rb_eArgError, "%s is not a valid category.", label_str);
@@ -269,7 +270,7 @@ rlog_color_set(VALUE self, VALUE label, VALUE color) {
269
270
  */
270
271
  static VALUE
271
272
  rlog_on_get(VALUE self, VALUE label) {
272
- LogCat cat = log_cat_find(StringValuePtr(label));
273
+ agooLogCat cat = agoo_log_cat_find(StringValuePtr(label));
273
274
 
274
275
  if (NULL == cat) {
275
276
  return Qfalse;
@@ -286,7 +287,7 @@ rlog_on_get(VALUE self, VALUE label) {
286
287
  static VALUE
287
288
  rlog_on_set(VALUE self, VALUE label, VALUE state) {
288
289
  const char *label_str = StringValuePtr(label);
289
- LogCat cat = log_cat_find(label_str);
290
+ agooLogCat cat = agoo_log_cat_find(label_str);
290
291
 
291
292
  if (NULL == cat) {
292
293
  rb_raise(rb_eArgError, "%s is not a valid category.", label_str);
@@ -305,12 +306,12 @@ rlog_on_set(VALUE self, VALUE label, VALUE state) {
305
306
  static VALUE
306
307
  rlog_log(VALUE self, VALUE label, VALUE msg) {
307
308
  const char *label_str = StringValuePtr(label);
308
- LogCat cat = log_cat_find(label_str);
309
+ agooLogCat cat = agoo_log_cat_find(label_str);
309
310
 
310
311
  if (NULL == cat) {
311
312
  rb_raise(rb_eArgError, "%s is not a valid category.", label_str);
312
313
  }
313
- log_cat(cat, "%s", StringValuePtr(msg));
314
+ agoo_log_cat(cat, "%s", StringValuePtr(msg));
314
315
 
315
316
  return Qnil;
316
317
  }
@@ -326,7 +327,7 @@ static VALUE
326
327
  rlog_flush(VALUE self, VALUE to) {
327
328
  double timeout = NUM2DBL(to);
328
329
 
329
- if (!log_flush(timeout)) {
330
+ if (!agoo_log_flush(timeout)) {
330
331
  rb_raise(rb_eStandardError, "timed out waiting for log flush.");
331
332
  }
332
333
  return Qnil;
@@ -340,7 +341,7 @@ rlog_flush(VALUE self, VALUE to) {
340
341
  */
341
342
  static VALUE
342
343
  rlog_rotate(VALUE self) {
343
- log_rotate();
344
+ agoo_log_rotate();
344
345
  return Qnil;
345
346
  }
346
347
 
@@ -352,7 +353,7 @@ rlog_rotate(VALUE self) {
352
353
  */
353
354
  static VALUE
354
355
  rlog_console(VALUE self, VALUE on) {
355
- the_log.console = (Qtrue == on);
356
+ agoo_log.console = (Qtrue == on);
356
357
  return Qnil;
357
358
  }
358
359
 
@@ -364,7 +365,7 @@ rlog_console(VALUE self, VALUE on) {
364
365
  */
365
366
  static VALUE
366
367
  rlog_classic(VALUE self) {
367
- the_log.classic = true;
368
+ agoo_log.classic = true;
368
369
  return Qnil;
369
370
  }
370
371
 
@@ -376,7 +377,7 @@ rlog_classic(VALUE self) {
376
377
  */
377
378
  static VALUE
378
379
  rlog_json(VALUE self) {
379
- the_log.classic = false;
380
+ agoo_log.classic = false;
380
381
  return Qnil;
381
382
  }
382
383
 
@@ -391,7 +392,7 @@ rlog_max_size(VALUE self, VALUE rmax) {
391
392
  int max = FIX2INT(rmax);
392
393
 
393
394
  if (1 <= max) {
394
- the_log.max_size = max;
395
+ agoo_log.max_size = max;
395
396
  } else {
396
397
  rb_raise(rb_eArgError, "max_size must be 1 or more.");
397
398
  }
@@ -409,7 +410,7 @@ rlog_max_files(VALUE self, VALUE rmax) {
409
410
  int max = FIX2INT(rmax);
410
411
 
411
412
  if (1 <= max || max < 100) {
412
- the_log.max_files = max;
413
+ agoo_log.max_files = max;
413
414
  } else {
414
415
  rb_raise(rb_eArgError, "max_files must be between 1 and 100.");
415
416
  }
@@ -417,7 +418,7 @@ rlog_max_files(VALUE self, VALUE rmax) {
417
418
  }
418
419
 
419
420
  static void
420
- on_error(Err err) {
421
+ on_error(agooErr err) {
421
422
  rb_raise(rb_eStandardError, "%s", err->msg);
422
423
  }
423
424
 
@@ -429,6 +430,8 @@ on_error(Err err) {
429
430
  */
430
431
  void
431
432
  rlog_init(VALUE mod) {
433
+ struct _agooErr err = AGOO_ERR_INIT;
434
+
432
435
  log_mod = rb_define_module_under(mod, "Log");
433
436
 
434
437
  rb_define_module_function(log_mod, "configure", rlog_configure, 1);
@@ -463,8 +466,10 @@ rlog_init(VALUE mod) {
463
466
  rb_define_module_function(log_mod, "max_size=", rlog_max_size, 1);
464
467
  rb_define_module_function(log_mod, "max_files=", rlog_max_files, 1);
465
468
 
466
- the_log.on_error = on_error;
469
+ agoo_log.on_error = on_error;
467
470
 
468
- log_init("agoo");
469
- log_start(false);
471
+ agoo_log_init("agoo");
472
+ if (AGOO_ERR_OK != agoo_log_start(&err, false)) {
473
+ rb_raise(rb_eStandardError, "%s", err.msg);
474
+ }
470
475
  }