Index: trunk/willow/src/include/flowio.h |
— | — | @@ -162,7 +162,7 @@ |
163 | 163 | |
164 | 164 | sink_result data_ready(char const *buf, size_t len, ssize_t &discard); |
165 | 165 | sink_result data_empty(void) { |
166 | | - WDEBUG((WLOG_DEBUG, "socket_sink::data_empty")); |
| 166 | + WDEBUG("socket_sink::data_empty"); |
167 | 167 | _reg = false; |
168 | 168 | return sink_result_finished; |
169 | 169 | } |
— | — | @@ -323,7 +323,7 @@ |
324 | 324 | |
325 | 325 | sink_result data_empty () { |
326 | 326 | sink_result res; |
327 | | - WDEBUG((WLOG_DEBUG, "buffering_filter: data_empty")); |
| 327 | + WDEBUG("buffering_filter: data_empty"); |
328 | 328 | res = bf_eof(); |
329 | 329 | if (res != sink_result_finished) |
330 | 330 | return res; |
Index: trunk/willow/src/include/cache.h |
— | — | @@ -90,9 +90,8 @@ |
91 | 91 | * Assume it's valid if the time it was last validated is |
92 | 92 | * less than 25% greater than its age. |
93 | 93 | */ |
94 | | - WDEBUG((WLOG_DEBUG, |
95 | | - str(format("expired: now=%d, revalidating at %d") |
96 | | - % time(0) % _revalidate_at))); |
| 94 | + WDEBUG((format("expired: now=%d, revalidating at %d") |
| 95 | + % time(0) % _revalidate_at)); |
97 | 96 | if (_revalidate_at <= time(0)) { |
98 | 97 | _complete = false; |
99 | 98 | return true; |
— | — | @@ -269,13 +268,11 @@ |
270 | 269 | if (create) { |
271 | 270 | _file.open(path.c_str(), ios::out | ios::binary | ios::trunc); |
272 | 271 | if (!_file) |
273 | | - wlog(WLOG_WARNING, |
274 | | - format("creating cache file %s: %s") |
| 272 | + wlog.warn(format("creating cache file %s: %s") |
275 | 273 | % path % strerror(errno)); |
276 | 274 | }else { |
277 | 275 | if (stat(path.c_str(), &sb) == -1) { |
278 | | - wlog(WLOG_WARNING, |
279 | | - format("cache file %s: %s") |
| 276 | + wlog.warn(format("cache file %s: %s") |
280 | 277 | % path % strerror(errno)); |
281 | 278 | return; |
282 | 279 | } |
— | — | @@ -503,10 +500,9 @@ |
504 | 501 | ssize_t disc = 0; |
505 | 502 | io::sink_result res; |
506 | 503 | for (;;) { |
507 | | - WDEBUG((WLOG_DEBUG, |
508 | | - str(format("cached_spigot: %d left, off %d fd %d") |
| 504 | + WDEBUG(format("cached_spigot: %d left, off %d fd %d") |
509 | 505 | % (_ent->_data.size() - _off) |
510 | | - % _off % _ent->_data.fd()))); |
| 506 | + % _off % _ent->_data.fd()); |
511 | 507 | if (_dio) { |
512 | 508 | res = _sp_dio_ready(_ent->_data.fd(), _off, |
513 | 509 | _ent->_data.size() - _off, disc); |
— | — | @@ -518,23 +514,22 @@ |
519 | 515 | switch (res) { |
520 | 516 | case io::sink_result_finished: |
521 | 517 | _sp_completed_callee(); |
522 | | - WDEBUG((WLOG_DEBUG, "all finished")); |
| 518 | + WDEBUG("all finished"); |
523 | 519 | return; |
524 | 520 | case io::sink_result_okay: |
525 | 521 | if (_off == _ent->_data.size()) { |
526 | 522 | _sp_completed_callee(); |
527 | 523 | return; |
528 | 524 | } |
529 | | - WDEBUG((WLOG_DEBUG, "continuing")); |
| 525 | + WDEBUG("continuing"); |
530 | 526 | continue; |
531 | 527 | case io::sink_result_error: |
532 | | - WDEBUG((WLOG_DEBUG, str(format("error %s") |
533 | | - % strerror(errno)))); |
| 528 | + WDEBUG(format("error %s") % strerror(errno)); |
534 | 529 | _sp_error_callee(); |
535 | 530 | return; |
536 | 531 | case io::sink_result_blocked: |
537 | 532 | sp_cork(); |
538 | | - WDEBUG((WLOG_DEBUG, "blocked")); |
| 533 | + WDEBUG("blocked"); |
539 | 534 | return; |
540 | 535 | } |
541 | 536 | } |
Index: trunk/willow/src/include/wlog.h |
— | — | @@ -21,35 +21,51 @@ |
22 | 22 | #include "config.h" |
23 | 23 | #include "ptalloc.h" |
24 | 24 | |
25 | | -#define WLOG_DEBUG 0 |
26 | | -#define WLOG_NOTICE 1 |
27 | | -#define WLOG_WARNING 2 |
28 | | -#define WLOG_ERROR 3 |
29 | | -#define WLOG_MAX 3 |
| 25 | +enum log_level { |
| 26 | + ll_debug, |
| 27 | + ll_notice, |
| 28 | + ll_warn, |
| 29 | + ll_error |
| 30 | +}; |
30 | 31 | |
31 | | -extern struct log_variables { |
32 | | - string file; |
33 | | - int level; |
34 | | - ofstream fp; |
35 | | - bool syslog; |
36 | | - int facility; |
37 | | -} logging; |
| 32 | +struct logger { |
| 33 | + logger(); |
38 | 34 | |
39 | | -void wlog_init(void); |
40 | | -void wlog(int, string const &); |
| 35 | + void syslog (bool, int facility = 0); |
| 36 | + void level (log_level); |
| 37 | + bool file (string const &fname); |
41 | 38 | |
42 | | -template<typename charT, typename traits, typename allocator> |
43 | | -void wlog(int lev, basic_format<charT, traits, allocator> const &f) |
44 | | -{ |
45 | | - wlog(lev, str(f)); |
46 | | -} |
| 39 | + bool open(void); |
| 40 | + void close(void); |
47 | 41 | |
48 | | -void wlog_close(void); |
| 42 | + void debug (format const &f) { _log(ll_debug, str(f)); } |
| 43 | + void notice(format const &f) { _log(ll_notice, str(f));} |
| 44 | + void warn (format const &f) { _log(ll_warn, str(f)); } |
| 45 | + void error (format const &f) { _log(ll_error, str(f)); } |
49 | 46 | |
| 47 | + void debug (string const &s) { _log(ll_debug, s); } |
| 48 | + void notice(string const &s) { _log(ll_notice, s); } |
| 49 | + void warn (string const &s) { _log(ll_warn, s); } |
| 50 | + void error (string const &s) { _log(ll_error, s); } |
| 51 | + |
| 52 | +private: |
| 53 | + bool _syslog; |
| 54 | + int _facility; |
| 55 | + log_level _level; |
| 56 | + string _file; |
| 57 | + |
| 58 | + ofstream *_fp; |
| 59 | + lockable _lock; |
| 60 | + |
| 61 | + void _log(log_level l, string const &); |
| 62 | +}; |
| 63 | + |
| 64 | +extern logger wlog; |
| 65 | + |
50 | 66 | #ifndef WILLOW_DEBUG |
51 | 67 | # define WDEBUG(x) ((void)0) |
52 | 68 | #else |
53 | | -# define WDEBUG(x) wlog x |
| 69 | +# define WDEBUG(x) wlog.debug(x) |
54 | 70 | #endif |
55 | 71 | |
56 | 72 | #endif |
Index: trunk/willow/src/include/dbwrap.h |
— | — | @@ -244,9 +244,9 @@ |
245 | 245 | database<Key, Value, Datastore>::errcall(DB_ENV const *, char const *pfx, char const *msg) |
246 | 246 | { |
247 | 247 | if (pfx) |
248 | | - wlog(WLOG_WARNING, str(format("%s: %s") % pfx % msg)); |
| 248 | + wlog.warn(format("%s: %s") % pfx % msg); |
249 | 249 | else |
250 | | - wlog(WLOG_WARNING, msg); |
| 250 | + wlog.warn(msg); |
251 | 251 | } |
252 | 252 | |
253 | 253 | template<typename Key, typename Value, typename Datastore> |
Index: trunk/willow/src/libwillow/mbuffer.cc |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | marshalling_buffer::extract<imstring>(imstring &s) |
25 | 25 | { |
26 | 26 | size_t sz = 0; |
27 | | - WDEBUG((WLOG_DEBUG, "DB: extracting an imstring")); |
| 27 | + WDEBUG("DB: extracting an imstring"); |
28 | 28 | if (!extract<size_t>(sz)) |
29 | 29 | return false; |
30 | 30 | if (_size + sz > _bufsz) |
Index: trunk/willow/src/willow/cache.cc |
— | — | @@ -45,8 +45,8 @@ |
46 | 46 | if (it != _entities.end()) { |
47 | 47 | shared_ptr<cachedentity> ret(it->second); |
48 | 48 | /* entity was cached */ |
49 | | - WDEBUG((WLOG_DEBUG, str(format("[%s] cached, complete=%d") |
50 | | - % url % ret->_complete))); |
| 49 | + WDEBUG(format("[%s] cached, complete=%d") |
| 50 | + % url % ret->_complete); |
51 | 51 | wasnew = false; |
52 | 52 | _lru.erase(it); |
53 | 53 | it->second->reused(); |
— | — | @@ -63,21 +63,20 @@ |
64 | 64 | e = _db->get(url); |
65 | 65 | if (e != NULL) { |
66 | 66 | shared_ptr<cachedentity> ret(e); |
67 | | - WDEBUG((WLOG_DEBUG, |
68 | | - str(format("found [%s] in disk cache complete %d void %d") |
69 | | - % url % e->complete() % e->isvoid()))); |
| 67 | + WDEBUG(format("found [%s] in disk cache complete %d void %d") |
| 68 | + % url % e->complete() % e->isvoid()); |
70 | 69 | _lru.insert(_entities.insert(make_pair(url, ret)).first); |
71 | 70 | wasnew = false; |
72 | 71 | ret->ref(); |
73 | 72 | return ret; |
74 | 73 | } |
75 | 74 | if (_db->error() && _db->error() != DB_NOTFOUND) { |
76 | | - wlog(WLOG_WARNING, str(format("fetching cached data: %s") |
77 | | - % _db->strerror())); |
| 75 | + wlog.warn(format("fetching cached data: %s") |
| 76 | + % _db->strerror()); |
78 | 77 | } |
79 | 78 | } |
80 | 79 | |
81 | | - WDEBUG((WLOG_DEBUG, str(format("[%s] not cached") % url))); |
| 80 | + WDEBUG(format("[%s] not cached") % url); |
82 | 81 | if (!create) |
83 | 82 | return shared_ptr<cachedentity>(); |
84 | 83 | |
— | — | @@ -168,14 +167,14 @@ |
169 | 168 | void |
170 | 169 | httpcache::_swap_out(cachedentity *ent) |
171 | 170 | { |
172 | | - WDEBUG((WLOG_DEBUG, str(format("swapping out %s") % ent->url()))); |
| 171 | + WDEBUG(format("swapping out %s") % ent->url()); |
173 | 172 | HOLDING(_lock); |
174 | 173 | if (!_db) |
175 | 174 | return; |
176 | 175 | _db->put(ent->url(), *ent); |
177 | 176 | if (_db->error()) { |
178 | | - wlog(WLOG_WARNING, str(format("storing cached data: %s") |
179 | | - % _db->strerror())); |
| 177 | + wlog.warn(format("storing cached data: %s") |
| 178 | + % _db->strerror()); |
180 | 179 | } |
181 | 180 | } |
182 | 181 | |
— | — | @@ -218,9 +217,8 @@ |
219 | 218 | |
220 | 219 | _env = db::environment::open(config.cache_master); |
221 | 220 | if (_env->error()) { |
222 | | - wlog(WLOG_ERROR, |
223 | | - str(format("cannot open cache master environment \"%s\": %s") |
224 | | - % config.cache_master % _env->strerror())); |
| 221 | + wlog.error(format("cannot open cache master environment \"%s\": %s") |
| 222 | + % config.cache_master % _env->strerror()); |
225 | 223 | delete _env; |
226 | 224 | _env = NULL; |
227 | 225 | return false; |
— | — | @@ -229,9 +227,8 @@ |
230 | 228 | _db = _env->open_database<imstring, cachedentity, |
231 | 229 | cachedir_data_store>("objects", _store); |
232 | 230 | if (_db->error()) { |
233 | | - wlog(WLOG_ERROR, |
234 | | - str(format("cannot open cache master database \"%s\": %s") |
235 | | - % config.cache_master % _db->strerror())); |
| 231 | + wlog.error(format("cannot open cache master database \"%s\": %s") |
| 232 | + % config.cache_master % _db->strerror()); |
236 | 233 | _env->close(); |
237 | 234 | delete _env; |
238 | 235 | delete _db; |
— | — | @@ -246,22 +243,22 @@ |
247 | 244 | httpcache::create(void) |
248 | 245 | { |
249 | 246 | if (config.cache_master.empty()) { |
250 | | - wlog(WLOG_ERROR, "no cache master to create"); |
| 247 | + wlog.error("no cache master to create"); |
251 | 248 | return false; |
252 | 249 | } |
253 | 250 | |
254 | 251 | _store = new cachedir_data_store; |
255 | 252 | |
256 | 253 | if (mkdir(config.cache_master.c_str(), 0700) < 0) { |
257 | | - wlog(WLOG_ERROR, format("cannot create cache master \"%s\": %s") |
| 254 | + wlog.error(format("cannot create cache master \"%s\": %s") |
258 | 255 | % config.cache_master % strerror(errno)); |
259 | 256 | return false; |
260 | 257 | } |
261 | 258 | |
262 | 259 | _env = db::environment::create(config.cache_master); |
263 | 260 | if (_env->error()) { |
264 | | - wlog(WLOG_ERROR, |
265 | | - format("cannot create cache master environmet \"%s\": %s") |
| 261 | + wlog.error(format( |
| 262 | + "cannot create cache master environmet \"%s\": %s") |
266 | 263 | % config.cache_master % _env->strerror()); |
267 | 264 | delete _env; |
268 | 265 | _env = NULL; |
— | — | @@ -271,8 +268,8 @@ |
272 | 269 | _db = _env->create_database<imstring, cachedentity, |
273 | 270 | cachedir_data_store>("objects", _store); |
274 | 271 | if (_db->error()) { |
275 | | - wlog(WLOG_ERROR, |
276 | | - format("cannot create cache master database \"%s\": %s") |
| 272 | + wlog.error(format( |
| 273 | + "cannot create cache master database \"%s\": %s") |
277 | 274 | % config.cache_master % _db->strerror()); |
278 | 275 | _env->close(); |
279 | 276 | delete _env; |
Index: trunk/willow/src/willow/cachedentity.cc |
— | — | @@ -27,8 +27,7 @@ |
28 | 28 | , _expires(0) |
29 | 29 | , _modified(0) |
30 | 30 | { |
31 | | - WDEBUG((WLOG_DEBUG, format("CACHE: creating cached entity with URL %s") |
32 | | - % url)); |
| 31 | + WDEBUG(format("CACHE: creating cached entity with URL %s") % url); |
33 | 32 | assert(_url.size()); |
34 | 33 | } |
35 | 34 | |
— | — | @@ -49,7 +48,7 @@ |
50 | 49 | } |
51 | 50 | |
52 | 51 | if (!entitycache.cache_mem_increase(size, this)) { |
53 | | - WDEBUG((WLOG_DEBUG, "object is too large, voiding cache")); |
| 52 | + WDEBUG("object is too large, voiding cache"); |
54 | 53 | _void = true; |
55 | 54 | return; |
56 | 55 | } |
— | — | @@ -70,7 +69,7 @@ |
71 | 70 | cachedentity::set_complete(void) |
72 | 71 | { |
73 | 72 | header *h; |
74 | | - WDEBUG((WLOG_DEBUG, format("set_complete: void=%d") % _void)); |
| 73 | + WDEBUG(format("set_complete: void=%d") % _void); |
75 | 74 | if (_void) |
76 | 75 | return; |
77 | 76 | _headers.remove("transfer-encoding"); |
— | — | @@ -112,7 +111,7 @@ |
113 | 112 | return; |
114 | 113 | } |
115 | 114 | |
116 | | - WDEBUG((WLOG_DEBUG, format("CACHE: object lifetime=%d sec.") % _lifetime)); |
| 115 | + WDEBUG(format("CACHE: object lifetime=%d sec.") % _lifetime); |
117 | 116 | revalidated(); |
118 | 117 | _builthdrs = _headers.build(); |
119 | 118 | _builtsz = _headers.length(); |
— | — | @@ -157,8 +156,7 @@ |
158 | 157 | size_t bufsz; |
159 | 158 | if (!buf.extract<imstring>(url)) |
160 | 159 | return NULL; |
161 | | - WDEBUG((WLOG_DEBUG, format("unmarshall: URL [%s], len %d") |
162 | | - % url % url.size())); |
| 160 | + WDEBUG(format("unmarshall: URL [%s], len %d") % url % url.size()); |
163 | 161 | ret = new cachedentity(url); |
164 | 162 | if (!buf.extract<imstring>(ret->_status)) { |
165 | 163 | delete ret; |
— | — | @@ -242,10 +240,9 @@ |
243 | 241 | assert(f); |
244 | 242 | if (!f->okay()) |
245 | 243 | return false; |
246 | | - WDEBUG((WLOG_DEBUG, format("CACHE: writing cached data to %s") |
247 | | - % f->filename())); |
| 244 | + WDEBUG(format("CACHE: writing cached data to %s") % f->filename()); |
248 | 245 | if (!sm.write(_data.ptr(), _data.size())) { |
249 | | - wlog(WLOG_WARNING, format("writing cached data to %s: %s") |
| 246 | + wlog.warn(format("writing cached data to %s: %s") |
250 | 247 | % f->filename() % strerror(errno)); |
251 | 248 | return false; |
252 | 249 | } |
Index: trunk/willow/src/willow/whttp.cc |
— | — | @@ -392,9 +392,9 @@ |
393 | 393 | char dstr[64]; |
394 | 394 | struct tm tm; |
395 | 395 | time_t mod = _cachedent->modified(); |
396 | | - WDEBUG((WLOG_DEBUG, |
397 | | - format("HTTP: need to revalidate, %d refs") |
398 | | - % _cachedent->refs())); |
| 396 | + WDEBUG(format( |
| 397 | + "HTTP: need to revalidate, %d refs") |
| 398 | + % _cachedent->refs()); |
399 | 399 | gmtime_r(&mod, &tm); |
400 | 400 | /* need to revalidate */ |
401 | 401 | if (_cachedent->refs() == 1) { |
— | — | @@ -519,7 +519,7 @@ |
520 | 520 | void |
521 | 521 | httpcllr::header_read_error(void) |
522 | 522 | { |
523 | | - WDEBUG((WLOG_DEBUG, format("header read error errno=%s") % strerror(errno))); |
| 523 | + WDEBUG(format("header read error errno=%s") % strerror(errno)); |
524 | 524 | |
525 | 525 | if (_header_parser->_eof) { |
526 | 526 | force_end_request(); |
— | — | @@ -821,7 +821,7 @@ |
822 | 822 | snprintf(cache_hit_hdr, hsize, "HIT from %s", my_hostname); |
823 | 823 | snprintf(cache_miss_hdr, hsize, "MISS from %s", my_hostname); |
824 | 824 | |
825 | | - wlog(WLOG_NOTICE, format("whttp: starting %d worker threads") |
| 825 | + wlog.notice(format("whttp: starting %d worker threads") |
826 | 826 | % config.nthreads); |
827 | 827 | for (int i = 0; i < config.nthreads; ++i) { |
828 | 828 | http_thread *t = new http_thread; |
— | — | @@ -843,11 +843,11 @@ |
844 | 844 | map<wsocket *, listener *>::iterator lsnit; |
845 | 845 | |
846 | 846 | if (s->read((char *)socks, sizeof(socks)) < (int)sizeof(socks)) { |
847 | | - wlog(WLOG_ERROR, format("accept_wakeup: reading fd: %s") |
| 847 | + wlog.error(format("accept_wakeup: reading fd: %s") |
848 | 848 | % strerror(errno)); |
849 | 849 | exit(1); |
850 | 850 | } |
851 | | - WDEBUG((WLOG_DEBUG, format("accept_wakeup, lsnr = %d") % socks[1])); |
| 851 | + WDEBUG(format("accept_wakeup, lsnr = %d") % socks[1]); |
852 | 852 | s->readback(polycaller<wsocket *, int>(*this, |
853 | 853 | &http_thread::accept_wakeup), 0); |
854 | 854 | if ((lsnit = sock2lsn.find(socks[1])) == sock2lsn.end()) |
— | — | @@ -922,7 +922,7 @@ |
923 | 923 | if (config.access_log.size()) { |
924 | 924 | alf.open(config.access_log.c_str(), ofstream::app); |
925 | 925 | if (!alf.good()) { |
926 | | - wlog(WLOG_WARNING, format("opening %s: %s") |
| 926 | + wlog.warn(format("opening %s: %s") |
927 | 927 | % config.access_log % strerror(errno)); |
928 | 928 | } |
929 | 929 | } |
— | — | @@ -937,14 +937,14 @@ |
938 | 938 | config.udplog_port, st_dgram, "UDP logger", prio_norm); |
939 | 939 | udplog_sock->connect(); |
940 | 940 | } catch (socket_error &e) { |
941 | | - wlog(WLOG_WARNING, |
942 | | - format("connecting to UDP log host %s: %s; disabling UDP logging") |
| 941 | + wlog.warn(format( |
| 942 | + "connecting to UDP log host %s: %s; disabling UDP logging") |
943 | 943 | % config.udplog_host % e.what()); |
944 | 944 | return; |
945 | 945 | } |
946 | 946 | |
947 | 947 | do_udplog = true; |
948 | | - wlog(WLOG_NOTICE, format("UDP logging to %s%s, sample rate 1/%d") |
| 948 | + wlog.notice(format("UDP logging to %s%s, sample rate 1/%d") |
949 | 949 | % config.udplog_host |
950 | 950 | % udplog_sock->straddr() |
951 | 951 | % config.log_sample); |
— | — | @@ -1170,8 +1170,8 @@ |
1171 | 1171 | HOLDING(alf_lock); |
1172 | 1172 | |
1173 | 1173 | if (!(alf << line << endl)) { |
1174 | | - wlog(WLOG_ERROR, |
1175 | | - format("writing access log: %s; log will be closed") |
| 1174 | + wlog.error(format( |
| 1175 | + "writing access log: %s; log will be closed") |
1176 | 1176 | % strerror(errno)); |
1177 | 1177 | alf.close(); |
1178 | 1178 | } |
Index: trunk/willow/src/willow/chunking.cc |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | io::sink_result |
43 | 43 | chunking_filter::bf_eof(void) |
44 | 44 | { |
45 | | - WDEBUG((WLOG_DEBUG, "chunking_filter: EOF")); |
| 45 | + WDEBUG("chunking_filter: EOF"); |
46 | 46 | _buf.add("\r\n0\r\n\r\n", 7, false); |
47 | 47 | return io::sink_result_finished; |
48 | 48 | } |
Index: trunk/willow/src/willow/cachedir_data_store.cc |
— | — | @@ -30,12 +30,12 @@ |
31 | 31 | { |
32 | 32 | assert(dirn >= 0); |
33 | 33 | if (dirn > (int)_cachedirs.size()) { |
34 | | - wlog(WLOG_WARNING, |
35 | | - format("trying to open cachedir %d, but only %d configured") |
| 34 | + wlog.warn(format( |
| 35 | + "trying to open cachedir %d, but only %d configured") |
36 | 36 | % dirn % _cachedirs.size()); |
37 | | - wlog(WLOG_WARNING, |
| 37 | + wlog.warn( |
38 | 38 | "this probably means the cachedir configuration has been " |
39 | | - "changed but old cache-master data is being used"); |
| 39 | + "changed but old cache-master data is being used"); |
40 | 40 | return NULL; |
41 | 41 | } |
42 | 42 | return _cachedirs[dirn]->open(num); |
— | — | @@ -51,7 +51,7 @@ |
52 | 52 | int d; |
53 | 53 | { HOLDING(_lock); |
54 | 54 | d = _curdir++; |
55 | | - WDEBUG((WLOG_DEBUG, format("got cachedir %d of %d") % d % _cachedirs.size())); |
| 55 | + WDEBUG(format("got cachedir %d of %d") % d % _cachedirs.size()); |
56 | 56 | if (_curdir == _cachedirs.size()) |
57 | 57 | _curdir = 0; |
58 | 58 | } |
— | — | @@ -71,11 +71,11 @@ |
72 | 72 | * Read the cached data from the cachedir. |
73 | 73 | */ |
74 | 74 | ent = m.unmarshall(d); |
75 | | - WDEBUG((WLOG_DEBUG, format("CACHE: unmarshalling a cached entity, dir=%d") |
76 | | - % ent->cachedir())); |
| 75 | + WDEBUG(format("CACHE: unmarshalling a cached entity, dir=%d") |
| 76 | + % ent->cachedir()); |
77 | 77 | if (ent == NULL) |
78 | 78 | return NULL; |
79 | | - WDEBUG((WLOG_DEBUG, format("CACHE: loading cache data for %s") % ent->url())); |
| 79 | + WDEBUG(format("CACHE: loading cache data for %s") % ent->url()); |
80 | 80 | assert(ent->complete() && !ent->isvoid()); |
81 | 81 | ent->loadcachefile(); |
82 | 82 | return ent; |
— | — | @@ -97,8 +97,7 @@ |
98 | 98 | */ |
99 | 99 | cachefile *f = nextfile(); |
100 | 100 | o.savecachefile(f); |
101 | | - WDEBUG((WLOG_DEBUG, format("CACHE: storing %s, dir=%d") |
102 | | - % o.url() % o.cachedir())); |
| 101 | + WDEBUG(format("CACHE: storing %s, dir=%d") % o.url() % o.cachedir()); |
103 | 102 | ret = m.marshall(o); |
104 | 103 | delete f; |
105 | 104 | return ret; |
Index: trunk/willow/src/willow/wlog.cc |
— | — | @@ -30,8 +30,7 @@ |
31 | 31 | #include "wconfig.h" |
32 | 32 | #include "format.h" |
33 | 33 | |
34 | | -struct log_variables logging; |
35 | | -static lockable log_lock; |
| 34 | +logger wlog; |
36 | 35 | |
37 | 36 | static const char *sev_names[] = { |
38 | 37 | "Debug", |
— | — | @@ -47,43 +46,45 @@ |
48 | 47 | LOG_ERR, |
49 | 48 | }; |
50 | 49 | |
51 | | -void |
52 | | -wlog_init(void) |
| 50 | +bool |
| 51 | +logger::open(void) |
53 | 52 | { |
54 | | - if (logging.syslog) |
55 | | - openlog("willow", LOG_PID, logging.facility); |
| 53 | + if (_syslog) |
| 54 | + openlog("willow", LOG_PID, _facility); |
56 | 55 | |
57 | | - if (logging.file.empty()) |
58 | | - return; |
| 56 | + if (_file.empty()) |
| 57 | + return true; |
59 | 58 | |
60 | | - logging.fp.open(logging.file.c_str(), ios::app); |
61 | | - if (!logging.fp.is_open()) { |
62 | | - wlog(WLOG_ERROR, format("cannot open error log file %s: %s") |
63 | | - % logging.file % strerror(errno)); |
64 | | - exit(8); |
| 59 | + _fp = new ofstream(_file.c_str(), ios::app); |
| 60 | + if (!_fp->is_open()) { |
| 61 | + wlog.error(format("cannot open error log file %s: %s") |
| 62 | + % _file % strerror(errno)); |
| 63 | + delete _fp; |
| 64 | + _fp = NULL; |
| 65 | + return false; |
65 | 66 | } |
| 67 | + |
| 68 | + return true; |
66 | 69 | } |
67 | 70 | |
68 | 71 | void |
69 | | -wlog(int sev, string const &e) |
| 72 | +logger::_log(log_level sev, string const &e) |
70 | 73 | { |
71 | 74 | string r; |
72 | 75 | |
73 | | - if (sev > WLOG_MAX) |
74 | | - sev = WLOG_NOTICE; |
75 | | - if (sev < logging.level) |
| 76 | + if (sev < _level) |
76 | 77 | return; |
77 | 78 | |
78 | 79 | r = str(format("%s| %s: %s") % current_time_short % sev_names[sev] % e); |
79 | 80 | |
80 | | - HOLDING(log_lock); |
81 | | - if (logging.syslog) |
82 | | - syslog(syslog_pri[sev], "%s", e.c_str()); |
| 81 | + HOLDING(_lock); |
| 82 | + if (_syslog) |
| 83 | + ::syslog(syslog_pri[sev], "%s", e.c_str()); |
83 | 84 | |
84 | | - if (logging.fp.is_open()) { |
85 | | - if (!(logging.fp << r << '\n')) { |
86 | | - logging.fp.close(); |
87 | | - wlog(WLOG_ERROR, format("writing to logfile: %s") |
| 85 | + if (_fp) { |
| 86 | + if (!(*_fp << r << '\n')) { |
| 87 | + _fp->close(); |
| 88 | + wlog.error(format("writing to logfile: %s") |
88 | 89 | % strerror(errno)); |
89 | 90 | exit(8); |
90 | 91 | } |
— | — | @@ -94,11 +95,40 @@ |
95 | 96 | } |
96 | 97 | |
97 | 98 | void |
98 | | -wlog_close(void) |
| 99 | +logger::close(void) |
99 | 100 | { |
100 | | - if (logging.fp.is_open()) |
101 | | - logging.fp.close(); |
| 101 | + HOLDING(_lock); |
| 102 | + |
| 103 | + if (_fp) |
| 104 | + _fp->close(); |
102 | 105 | |
103 | | - if (logging.syslog) |
| 106 | + if (_syslog) |
104 | 107 | closelog(); |
105 | 108 | } |
| 109 | + |
| 110 | +void |
| 111 | +logger::syslog(bool do_, int facility) |
| 112 | +{ |
| 113 | + _syslog = do_; |
| 114 | + _facility = facility; |
| 115 | +} |
| 116 | + |
| 117 | +bool |
| 118 | +logger::file(string const &file) |
| 119 | +{ |
| 120 | + _file = file; |
| 121 | + return true; |
| 122 | +} |
| 123 | + |
| 124 | +void |
| 125 | +logger::level(log_level l) |
| 126 | +{ |
| 127 | + _level = l; |
| 128 | +} |
| 129 | + |
| 130 | +logger::logger(void) |
| 131 | + : _syslog(false) |
| 132 | + , _facility(0) |
| 133 | + , _level(ll_notice) |
| 134 | +{ |
| 135 | +} |
Index: trunk/willow/src/willow/willow.cc |
— | — | @@ -164,7 +164,8 @@ |
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | | - wlog_init(); |
| 168 | + if (!wlog.open()) |
| 169 | + return 1; |
169 | 170 | |
170 | 171 | if (zflag) { |
171 | 172 | if (!entitycache.create()) |
— | — | @@ -182,14 +183,14 @@ |
183 | 184 | stats_init(); |
184 | 185 | htcp_init(); |
185 | 186 | |
186 | | - wlog(WLOG_NOTICE, "running"); |
| 187 | + wlog.notice("running"); |
187 | 188 | |
188 | 189 | if (!config.foreground) |
189 | 190 | daemon(0, 0); |
190 | 191 | |
191 | 192 | ioloop->run(); |
192 | | - wlog(WLOG_NOTICE, "shutting down"); |
193 | | - wlog_close(); |
| 193 | + wlog.notice("shutting down"); |
| 194 | + wlog.close(); |
194 | 195 | whttp_shutdown(); |
195 | 196 | entitycache.close(); |
196 | 197 | |
— | — | @@ -205,7 +206,7 @@ |
206 | 207 | if (count++) |
207 | 208 | abort(); |
208 | 209 | |
209 | | - wlog(WLOG_ERROR, "fatal: out of memory. exiting."); |
| 210 | + wlog.error("fatal: out of memory. exiting."); |
210 | 211 | exit(8); |
211 | 212 | } |
212 | 213 | |
— | — | @@ -393,7 +394,7 @@ |
394 | 395 | try { |
395 | 396 | alist = addrlist::resolve(hstr, pstr, st_dgram); |
396 | 397 | } catch (socket_error &e) { |
397 | | - wlog(WLOG_WARNING, format("resolving [%s]:%s: %s") |
| 398 | + wlog.warn(format("resolving [%s]:%s: %s") |
398 | 399 | % hstr % pstr % e.what()); |
399 | 400 | return; |
400 | 401 | } |
— | — | @@ -405,8 +406,7 @@ |
406 | 407 | sock = it->makesocket("statistics listener", prio_stats); |
407 | 408 | sock->nonblocking(true); |
408 | 409 | } catch (socket_error &e) { |
409 | | - wlog(WLOG_WARNING, |
410 | | - format("creating statistics listener: %s:%s: %s") |
| 410 | + wlog.warn(format("creating statistics listener: %s:%s: %s") |
411 | 411 | % ip.first % ip.second % e.what()); |
412 | 412 | delete sock; |
413 | 413 | continue; |
— | — | @@ -415,8 +415,7 @@ |
416 | 416 | try { |
417 | 417 | sock->bind(); |
418 | 418 | } catch (socket_error &e) { |
419 | | - wlog(WLOG_WARNING, |
420 | | - format("binding statistics listener %s: %s") |
| 419 | + wlog.warn(format("binding statistics listener %s: %s") |
421 | 420 | % it->straddr() % e.what()); |
422 | 421 | delete sock; |
423 | 422 | continue; |
— | — | @@ -424,7 +423,7 @@ |
425 | 424 | |
426 | 425 | sock->readback(polycaller<wsocket *, int>(stats_handler, |
427 | 426 | &stats_handler_stru::callback), 0); |
428 | | - wlog(WLOG_NOTICE, format("statistics listener: %s") |
| 427 | + wlog.notice(format("statistics listener: %s") |
429 | 428 | % sock->straddr()); |
430 | 429 | } |
431 | 430 | } |
— | — | @@ -454,7 +453,7 @@ |
455 | 454 | munmap(_buf, _size); |
456 | 455 | _size = newsize; |
457 | 456 | _reserved = pagesize * (newsize / pagesize + 1); |
458 | | - WDEBUG((WLOG_DEBUG, format("new size %d reserved %d") % _size % _reserved)); |
| 457 | + WDEBUG(format("new size %d reserved %d") % _size % _reserved); |
459 | 458 | lseek(_fd, _reserved, SEEK_SET); |
460 | 459 | write(_fd, "", 1); |
461 | 460 | _buf = (char *)mmap(0, _reserved, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, 0); |
— | — | @@ -493,7 +492,7 @@ |
494 | 493 | , _size(0) |
495 | 494 | , _reserved(pagesize * (size / pagesize + 1)) |
496 | 495 | { |
497 | | - WDEBUG((WLOG_DEBUG, format("reserved: %d") % _reserved)); |
| 496 | + WDEBUG(format("reserved: %d") % _reserved); |
498 | 497 | |
499 | 498 | if (size == 0) |
500 | 499 | _reserved = size = pagesize; |
— | — | @@ -506,7 +505,7 @@ |
507 | 506 | snprintf(path, sizeof(path), "/dev/shm/willow.diobuf.%d.%d.%d", |
508 | 507 | (int) getpid(), (int) pthread_self(), rand()); |
509 | 508 | if ((_fd = open(path, O_CREAT | O_EXCL | O_RDWR, 0600)) == -1) { |
510 | | - wlog(WLOG_WARNING, format("opening diobuf %s: %s") |
| 509 | + wlog.warn(format("opening diobuf %s: %s") |
511 | 510 | % path % strerror(errno)); |
512 | 511 | _buf = new char[size]; |
513 | 512 | return; |
— | — | @@ -514,7 +513,7 @@ |
515 | 514 | unlink(path); |
516 | 515 | |
517 | 516 | if (lseek(_fd, _reserved, SEEK_SET) == -1) { |
518 | | - wlog(WLOG_WARNING, format("seeking diobuf %s: %s") |
| 517 | + wlog.warn(format("seeking diobuf %s: %s") |
519 | 518 | % path % strerror(errno)); |
520 | 519 | close(_fd); |
521 | 520 | _fd = -1; |
— | — | @@ -523,7 +522,7 @@ |
524 | 523 | } |
525 | 524 | |
526 | 525 | if (write(_fd, "", 1) < 1) { |
527 | | - wlog(WLOG_WARNING, format("extending diobuf %s: %s") |
| 526 | + wlog.warn(format("extending diobuf %s: %s") |
528 | 527 | % path % strerror(errno)); |
529 | 528 | close(_fd); |
530 | 529 | _fd = -1; |
— | — | @@ -533,7 +532,7 @@ |
534 | 533 | |
535 | 534 | _buf = (char *)mmap(0, _reserved, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, 0); |
536 | 535 | if (_buf == MAP_FAILED) { |
537 | | - wlog(WLOG_WARNING, format("mapping diobuf %s: %s") |
| 536 | + wlog.warn(format("mapping diobuf %s: %s") |
538 | 537 | % path % strerror(errno)); |
539 | 538 | close(_fd); |
540 | 539 | _fd = -1; |
Index: trunk/willow/src/willow/wnet.cc |
— | — | @@ -99,7 +99,7 @@ |
100 | 100 | { |
101 | 101 | size_t i; |
102 | 102 | |
103 | | - wlog(WLOG_NOTICE, format("maximum number of open files: %d") |
| 103 | + wlog.notice(format("maximum number of open files: %d") |
104 | 104 | % getdtablesize()); |
105 | 105 | |
106 | 106 | signal(SIGPIPE, SIG_IGN); |
— | — | @@ -112,14 +112,14 @@ |
113 | 113 | lns->sock->bind(); |
114 | 114 | lns->sock->listen(); |
115 | 115 | } catch (socket_error &e) { |
116 | | - wlog(WLOG_ERROR, format("creating listener %s: %s") |
| 116 | + wlog.error(format("creating listener %s: %s") |
117 | 117 | % lns->sock->straddr() % e.what()); |
118 | 118 | exit(8); |
119 | 119 | } |
120 | 120 | |
121 | 121 | lns->sock->readback(polycaller<wsocket *, int>(*this, &ioloop_t::_accept), 0); |
122 | 122 | } |
123 | | - wlog(WLOG_NOTICE, format("wnet: initialised, using libevent %s (%s)") |
| 123 | + wlog.notice(format("wnet: initialised, using libevent %s (%s)") |
124 | 124 | % event_get_version() % event_get_method()); |
125 | 125 | secondly_sched(); |
126 | 126 | } |
— | — | @@ -135,8 +135,7 @@ |
136 | 136 | if ((errno != ENFILE && errno != EMFILE) || (now - last_nfile) > 60) { |
137 | 137 | if (errno == ENFILE || errno == EMFILE) |
138 | 138 | last_nfile = now; |
139 | | - wlog(WLOG_NOTICE, format("accept error: %s") |
140 | | - % strerror(errno)); |
| 139 | + wlog.warn(format("accept error: %s") % strerror(errno)); |
141 | 140 | } |
142 | 141 | s->readback(polycaller<wsocket *, int>(*this, &ioloop_t::_accept), 0); |
143 | 142 | return; |
— | — | @@ -151,10 +150,10 @@ |
152 | 151 | char buf[sizeof(wsocket *) * 2]; |
153 | 152 | memcpy(buf, &newe, sizeof(newe)); |
154 | 153 | memcpy(buf + sizeof(newe), &s, sizeof(s)); |
155 | | - WDEBUG((WLOG_DEBUG, format("_accept, lsnr=%d") % s)); |
| 154 | + WDEBUG(format("_accept, lsnr=%d") % s); |
156 | 155 | |
157 | 156 | if (awaks[cawak]->write(buf, sizeof(wsocket *) * 2) < 0) { |
158 | | - wlog(WLOG_ERROR, format("writing to thread wakeup socket: %s") |
| 157 | + wlog.error(format("writing to thread wakeup socket: %s") |
159 | 158 | % strerror(errno)); |
160 | 159 | exit(1); |
161 | 160 | } |
— | — | @@ -188,10 +187,10 @@ |
189 | 188 | { |
190 | 189 | wsocket *s = (wsocket *)d; |
191 | 190 | |
192 | | - WDEBUG((WLOG_DEBUG, format("_ev_callback: %s%son %d (%s)") |
| 191 | + WDEBUG(format("_ev_callback: %s%son %d (%s)") |
193 | 192 | % ((ev & EV_READ) ? "read " : "") |
194 | 193 | % ((ev & EV_WRITE) ? "write " : "") |
195 | | - % fd % s->_desc)); |
| 194 | + % fd % s->_desc); |
196 | 195 | |
197 | 196 | if (ev & EV_READ) |
198 | 197 | s->_read_handler(s); |
— | — | @@ -204,10 +203,10 @@ |
205 | 204 | { |
206 | 205 | int ev_flags = 0; |
207 | 206 | |
208 | | - WDEBUG((WLOG_DEBUG, format("_register: %s%son %d (%s)") |
| 207 | + WDEBUG(format("_register: %s%son %d (%s)") |
209 | 208 | % ((what & FDE_READ) ? "read " : "") |
210 | 209 | % ((what & FDE_WRITE) ? "write " : "") |
211 | | - % _s % _desc)); |
| 210 | + % _s % _desc); |
212 | 211 | |
213 | 212 | if (event_pending(&ev, EV_READ | EV_WRITE, NULL)) |
214 | 213 | event_del(&ev); |
— | — | @@ -441,7 +440,7 @@ |
442 | 441 | int i; |
443 | 442 | if ((i = ::recvfrom(_s, buf, count, 0, (sockaddr *)&saddr, &addrlen)) < 0) |
444 | 443 | return i; |
445 | | - WDEBUG((WLOG_DEBUG, format("recvfrom: fam=%d") % saddr.ss_family)); |
| 444 | + WDEBUG(format("recvfrom: fam=%d") % saddr.ss_family); |
446 | 445 | addr = wnet::address((sockaddr *)&saddr, addrlen); |
447 | 446 | return i; |
448 | 447 | } |
— | — | @@ -578,8 +577,8 @@ |
579 | 578 | memset(&mr, 0, sizeof(mr)); |
580 | 579 | mr.imr_multiaddr.s_addr = inbind->sin_addr.s_addr; |
581 | 580 | mr.imr_interface.s_addr = inif->sin_addr.s_addr; |
582 | | - WDEBUG((WLOG_DEBUG, format("NET: %s joins mcast on if %s") |
583 | | - % straddr() % ifaddr.straddr())); |
| 581 | + WDEBUG(format("NET: %s joins mcast on if %s") |
| 582 | + % straddr() % ifaddr.straddr()); |
584 | 583 | setopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, &mr, sizeof(mr)); |
585 | 584 | break; |
586 | 585 | } |
Index: trunk/willow/src/willow/wbackend.cc |
— | — | @@ -56,8 +56,8 @@ |
57 | 57 | , be_hash(_carp_hosthash(be_straddr)) |
58 | 58 | , be_load(1.) |
59 | 59 | { |
60 | | - WDEBUG((WLOG_DEBUG, format("adding backend with straddr [%s], hash %s") |
61 | | - % be_straddr % be_hash)); |
| 60 | + WDEBUG(format("adding backend with straddr [%s], hash %s") |
| 61 | + % be_straddr % be_hash); |
62 | 62 | } |
63 | 63 | |
64 | 64 | backend_pool::backend_pool(string const &name, lb_type lbt, int failgroup) |
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | , _name(name) |
67 | 67 | , _failgroup(failgroup) |
68 | 68 | { |
69 | | - WDEBUG((WLOG_DEBUG, format("creating backend_pool, lbt=%d") % (int) lbt)); |
| 69 | + WDEBUG(format("creating backend_pool, lbt=%d") % (int) lbt); |
70 | 70 | } |
71 | 71 | |
72 | 72 | void |
— | — | @@ -75,8 +75,7 @@ |
76 | 76 | try { |
77 | 77 | list = addrlist::resolve(addr, port, st_stream, family); |
78 | 78 | } catch (resolution_error &e) { |
79 | | - wlog(WLOG_ERROR, format("resolving %s: %s") |
80 | | - % addr % e.what()); |
| 79 | + wlog.error(format("resolving %s: %s") % addr % e.what()); |
81 | 80 | return; |
82 | 81 | } |
83 | 82 | |
— | — | @@ -84,7 +83,7 @@ |
85 | 84 | |
86 | 85 | for (; it != end; ++it) { |
87 | 86 | backends.push_back(new backend(addr, *it)); |
88 | | - wlog(WLOG_NOTICE, format("backend server: %s%s") |
| 87 | + wlog.notice(format("backend server: %s%s") |
89 | 88 | % addr % it->straddr()); |
90 | 89 | } |
91 | 90 | |
— | — | @@ -131,8 +130,7 @@ |
132 | 131 | s->nonblocking(true); |
133 | 132 | } catch (socket_error &e) { |
134 | 133 | if (e.err() != ENFILE || now - last_nfile > 60) |
135 | | - wlog(WLOG_WARNING, |
136 | | - format("opening backend socket: %s") |
| 134 | + wlog.warn(format("opening backend socket: %s") |
137 | 135 | % e.what()); |
138 | 136 | if (e.err() == ENFILE) |
139 | 137 | last_nfile = now; |
— | — | @@ -146,7 +144,7 @@ |
147 | 145 | cs = s->connect(); |
148 | 146 | } catch (socket_error &e) { |
149 | 147 | time_t retry = time(NULL) + config.backend_retry; |
150 | | - wlog(WLOG_WARNING, format("%s: %s; retry in %d seconds") |
| 148 | + wlog.warn(format("%s: %s; retry in %d seconds") |
151 | 149 | % cbd->bc_backend->be_name |
152 | 150 | % e.what() % config.backend_retry); |
153 | 151 | cbd->bc_backend->be_dead = 1; |
— | — | @@ -174,7 +172,7 @@ |
175 | 173 | |
176 | 174 | if (error && error != EINPROGRESS) { |
177 | 175 | time_t retry = time(NULL) + config.backend_retry; |
178 | | - wlog(WLOG_WARNING, format("%s: %s; retry in %d seconds") |
| 176 | + wlog.warn(format("%s: %s; retry in %d seconds") |
179 | 177 | % cbd->bc_backend->be_name |
180 | 178 | % strerror(error) |
181 | 179 | % config.backend_retry); |
— | — | @@ -205,7 +203,7 @@ |
206 | 204 | , _failgroup(failgroup) |
207 | 205 | , _delegate(NULL) |
208 | 206 | { |
209 | | - WDEBUG((WLOG_DEBUG, format("lbt = %d") % (int)lbt)); |
| 207 | + WDEBUG(format("lbt = %d") % (int)lbt); |
210 | 208 | rotate(backends.begin(), backends.begin() + cur, backends.end()); |
211 | 209 | if (lbt == lb_carp || lbt == lb_carp_hostonly) |
212 | 210 | _carp_recalc(url, host, lbt); |
— | — | @@ -331,7 +329,8 @@ |
332 | 330 | hash = rotl(hash, 21); |
333 | 331 | hash *= (uint32_t) backends[i]->be_carplfm; |
334 | 332 | backends[i]->be_carp = hash; |
335 | | - WDEBUG((WLOG_DEBUG, format("host for CARP: [%s] -> %d, be hash %d") % s % hash % backends[i]->be_hash)); |
| 333 | + WDEBUG(format("host for CARP: [%s] -> %d, be hash %d") |
| 334 | + % s % hash % backends[i]->be_hash); |
336 | 335 | } |
337 | 336 | sort(backends.begin(), backends.end(), _becarp_cmp); |
338 | 337 | } |
Index: trunk/willow/src/willow/whttp_header.cc |
— | — | @@ -390,15 +390,13 @@ |
391 | 391 | size_t vlen, nlen, rnpos; |
392 | 392 | int htype; |
393 | 393 | |
394 | | - WDEBUG((WLOG_DEBUG, format("header parser: got [%s]") |
395 | | - % string(buf, buf + len))); |
| 394 | + WDEBUG(format("header parser: got [%s]") % string(buf, buf + len)); |
396 | 395 | while ((rn = find_rn(bufp, bufp + len)) != NULL) { |
397 | | - WDEBUG((WLOG_DEBUG, format("processing: [%s]") |
398 | | - % string(bufp, rn))); |
| 396 | + WDEBUG(format("processing: [%s]") % string(bufp, rn)); |
399 | 397 | for (char const *c = bufp; c < rn; ++c) |
400 | 398 | if (*(unsigned char *)c > 0x7f || !*c) |
401 | 399 | return io::sink_result_error; |
402 | | - WDEBUG((WLOG_DEBUG, "chars all okay")); |
| 400 | + WDEBUG("chars all okay"); |
403 | 401 | |
404 | 402 | if (rn == bufp) { |
405 | 403 | _sink_spigot->sp_cork(); |
— | — | @@ -556,9 +554,9 @@ |
557 | 555 | _http_vers = http11; |
558 | 556 | else return -1; |
559 | 557 | |
560 | | - WDEBUG((WLOG_DEBUG, format("parse_response: codelen=%d [%s] desclen=%d [%s]") |
| 558 | + WDEBUG(format("parse_response: codelen=%d [%s] desclen=%d [%s]") |
561 | 559 | % codelen % string(errcode, errcode + codelen) |
562 | | - % desclen % string(errdesc, errdesc + desclen))); |
| 560 | + % desclen % string(errdesc, errdesc + desclen)); |
563 | 561 | |
564 | 562 | _response = str10toint(errcode, codelen); |
565 | 563 | _http_path.reserve(codelen + desclen + 1); |
Index: trunk/willow/src/willow/dbwrap.cc |
— | — | @@ -82,7 +82,7 @@ |
83 | 83 | { |
84 | 84 | _error = env->_env->txn_begin(env->_env, NULL, &_txn, 0); |
85 | 85 | if (_error != 0) { |
86 | | - wlog(WLOG_WARNING, format("error starting transaction: %s") |
| 86 | + wlog.warn(format("error starting transaction: %s") |
87 | 87 | % strerror()); |
88 | 88 | _txn = NULL; |
89 | 89 | } |
Index: trunk/willow/src/willow/confparse.cc |
— | — | @@ -71,8 +71,7 @@ |
72 | 72 | } |
73 | 73 | |
74 | 74 | if ((yyin = fopen(file.c_str(), "r")) == NULL) { |
75 | | - wlog(WLOG_ERROR, |
76 | | - format("could not open configuration file %s: %s") |
| 75 | + wlog.error(format("could not open configuration file %s: %s") |
77 | 76 | % file % strerror(errno)); |
78 | 77 | return NULL; |
79 | 78 | } |
— | — | @@ -153,7 +152,7 @@ |
154 | 153 | while (isspace(*dir)) |
155 | 154 | dir++; |
156 | 155 | |
157 | | - WDEBUG((WLOG_DEBUG, format("PARSE: if[n]def %s") % dir)); |
| 156 | + WDEBUG(format("PARSE: if[n]def %s") % dir); |
158 | 157 | return if_parser.variable_defined(dir); |
159 | 158 | } |
160 | 159 | |
— | — | @@ -169,7 +168,7 @@ |
170 | 169 | name = str.substr(0, i); |
171 | 170 | value = str.substr(i + 1); |
172 | 171 | |
173 | | - WDEBUG((WLOG_DEBUG, format("add var: [%s] = [%s]") % name % value)); |
| 172 | + WDEBUG(format("add var: [%s] = [%s]") % name % value); |
174 | 173 | if_parser.add_variable(name, strtoll(value.c_str(), NULL, 0)); |
175 | 174 | } |
176 | 175 | |
— | — | @@ -379,8 +378,7 @@ |
380 | 379 | vsnprintf(msg, sizeof msg, fmt, ap); |
381 | 380 | va_end(ap); |
382 | 381 | |
383 | | - wlog(WLOG_ERROR, format("%s(%d): %s") |
384 | | - % current_file % lineno % msg); |
| 382 | + wlog.error(format("%s(%d): %s") % current_file % lineno % msg); |
385 | 383 | } |
386 | 384 | |
387 | 385 | void |
— | — | @@ -388,7 +386,7 @@ |
389 | 387 | { |
390 | 388 | char msg[1024] = { 0 }; |
391 | 389 | vsnprintf(msg, sizeof msg, fmt, ap); |
392 | | - wlog(WLOG_ERROR, format("%s: %s") % cv_pos.format() % msg); |
| 390 | + wlog.error(format("%s: %s") % cv_pos.format() % msg); |
393 | 391 | } |
394 | 392 | |
395 | 393 | void |
— | — | @@ -417,7 +415,7 @@ |
418 | 416 | { |
419 | 417 | char msg[1024] = { 0 }; |
420 | 418 | vsnprintf(msg, sizeof msg, fmt, ap); |
421 | | - wlog(WLOG_ERROR, format("%s: %s") % item_pos.format() % msg); |
| 419 | + wlog.error(format("%s: %s") % item_pos.format() % msg); |
422 | 420 | } |
423 | 421 | |
424 | 422 | void |
— | — | @@ -437,7 +435,7 @@ |
438 | 436 | va_start(ap, fmt); |
439 | 437 | vsnprintf(msg, sizeof msg, fmt, ap); |
440 | 438 | va_end(ap); |
441 | | - wlog(WLOG_ERROR, format("%s(%d): catastrophic error: %s") |
| 439 | + wlog.error(format("%s(%d): catastrophic error: %s") |
442 | 440 | % current_file % lineno % msg); |
443 | 441 | parse_error = true; |
444 | 442 | } |
— | — | @@ -446,8 +444,7 @@ |
447 | 445 | yyerror(const char *err) |
448 | 446 | { |
449 | 447 | parse_error = true; |
450 | | - wlog(WLOG_ERROR, format("%s(%d): %s") |
451 | | - % current_file % lineno % err); |
| 448 | + wlog.error(format("%s(%d): %s") % current_file % lineno % err); |
452 | 449 | } |
453 | 450 | |
454 | 451 | void |
Index: trunk/willow/src/willow/wconfig.cc |
— | — | @@ -115,8 +115,7 @@ |
116 | 116 | try { |
117 | 117 | res = addrlist::resolve(e.item_key, port, st_stream, fam); |
118 | 118 | } catch (socket_error &ex) { |
119 | | - wlog(WLOG_ERROR, format("resolving %s: %s") |
120 | | - % e.item_key % ex.what()); |
| 119 | + wlog.error(format("resolving %s: %s") % e.item_key % ex.what()); |
121 | 120 | return; |
122 | 121 | } |
123 | 122 | |
— | — | @@ -128,14 +127,13 @@ |
129 | 128 | try { |
130 | 129 | nl->sock = it->makesocket("HTTP listener", prio_accept); |
131 | 130 | } catch (socket_error &ex) { |
132 | | - wlog(WLOG_DEBUG, format("creating listener %s: %s") |
| 131 | + wlog.error(format("creating listener %s: %s") |
133 | 132 | % e.item_key % ex.what()); |
134 | 133 | delete nl; |
135 | 134 | delete res; |
136 | 135 | return; |
137 | 136 | } |
138 | | - WDEBUG((WLOG_DEBUG, format("listener %d has group %d") |
139 | | - % nl->sock % gn)); |
| 137 | + WDEBUG(format("listener %d has group %d") % nl->sock % gn); |
140 | 138 | sock2lsn[nl->sock] = nl; |
141 | 139 | used_pools.insert(gn); |
142 | 140 | |
— | — | @@ -143,7 +141,7 @@ |
144 | 142 | nl->name = e.item_key; |
145 | 143 | nl->group = gn; |
146 | 144 | listeners.push_back(nl); |
147 | | - wlog(WLOG_NOTICE, format("listening on %s%s (group %d)") |
| 145 | + wlog.notice(format("listening on %s%s (group %d)") |
148 | 146 | % e.item_key % it->straddr() % gn); |
149 | 147 | } |
150 | 148 | delete res; |
— | — | @@ -191,8 +189,7 @@ |
192 | 190 | static void |
193 | 191 | set_log_facility(tree_entry &, value &v) |
194 | 192 | { |
195 | | - logging.syslog = true; |
196 | | - logging.facility = log_levels.find(v.cv_values[0].av_strval)->second; |
| 193 | + wlog.syslog(true, log_levels.find(v.cv_values[0].av_strval)->second); |
197 | 194 | } |
198 | 195 | |
199 | 196 | static bool |
— | — | @@ -361,7 +358,7 @@ |
362 | 359 | } |
363 | 360 | } |
364 | 361 | |
365 | | - WDEBUG((WLOG_DEBUG, format("adding backend %d type = %d") % gn % (int) lbtype)); |
| 362 | + WDEBUG(format("adding backend %d type = %d") % gn % (int) lbtype); |
366 | 363 | bpools.insert(make_pair(gn, backend_pool(e.item_key, lbtype, fogroup))); |
367 | 364 | |
368 | 365 | if ((v = e/"hosts") != NULL) { |
— | — | @@ -430,6 +427,18 @@ |
431 | 428 | } |
432 | 429 | } |
433 | 430 | |
| 431 | +void |
| 432 | +set_log_level(tree_entry &e, value &v) |
| 433 | +{ |
| 434 | + wlog.level(log_level(v.cv_values[0].av_intval)); |
| 435 | +} |
| 436 | + |
| 437 | +void |
| 438 | +set_log_file(tree_entry &e, value &v) |
| 439 | +{ |
| 440 | + wlog.file(v.cv_values[0].av_strval); |
| 441 | +} |
| 442 | + |
434 | 443 | bool |
435 | 444 | read_config(string const &file) |
436 | 445 | { |
— | — | @@ -437,10 +446,10 @@ |
438 | 447 | tree *t; |
439 | 448 | conf |
440 | 449 | .block("log") |
441 | | - .value("level", simple_range(0, 3), set_int(logging.level)) |
442 | | - .value("file", nonempty_qstring, set_qstring(logging.file)) |
443 | | - .value("syslog", simple_yesno, set_yesno(logging.syslog)) |
444 | | - .value("facility", func(validate_log_facility), func(set_log_facility)) |
| 450 | + .value("level", simple_range(0, 3), func(set_log_level)) |
| 451 | + .value("file", nonempty_qstring, func(set_log_file)) |
| 452 | + .value("syslog-facility", |
| 453 | + func(validate_log_facility), func(set_log_facility)) |
445 | 454 | .value("access-log", nonempty_qstring, set_qstring(config.access_log)) |
446 | 455 | .value("log-sample", simple_range(1, INT_MAX), set_int(config.log_sample)) |
447 | 456 | .value("udp-log", func(v_udp_log), set_yesno(config.udp_log)) |
— | — | @@ -543,35 +552,36 @@ |
544 | 553 | file = CONFIGFILE; |
545 | 554 | conf::current_file = file; |
546 | 555 | |
547 | | - wlog(WLOG_NOTICE, format("loading configuration from %s") |
| 556 | + wlog.notice(format("loading configuration from %s") |
548 | 557 | % conf::current_file); |
549 | 558 | |
550 | 559 | if (!read_config(file)) { |
551 | | - wlog(WLOG_ERROR, "cannot load configuration"); |
| 560 | + wlog.error("cannot load configuration"); |
552 | 561 | nerrors++; |
553 | 562 | } |
554 | 563 | |
555 | 564 | if (!listeners.size()) { |
556 | | - wlog(WLOG_ERROR, "no listeners defined"); |
| 565 | + wlog.error("no listeners defined"); |
557 | 566 | nerrors++; |
558 | 567 | } |
559 | 568 | if (!bpools.size()) { |
560 | | - wlog(WLOG_ERROR, "no backends defined"); |
| 569 | + wlog.error("no backends defined"); |
561 | 570 | nerrors++; |
562 | 571 | } |
563 | 572 | |
564 | 573 | for (map<int, backend_pool>::iterator it = bpools.begin(), end = bpools.end(); |
565 | 574 | it != end; ++it) { |
566 | 575 | if (!it->second.size() && used_pools.find(it->first) != used_pools.end()) { |
567 | | - wlog(WLOG_ERROR, format("backend group \"%s\" is used but has no backends") |
| 576 | + wlog.error(format( |
| 577 | + "backend group \"%s\" is used but has no backends") |
568 | 578 | % it->second.name()); |
569 | 579 | nerrors++; |
570 | 580 | } |
571 | 581 | } |
572 | 582 | |
573 | 583 | if (nerrors) { |
574 | | - wlog(WLOG_ERROR, |
575 | | - format("%d error(s) in configuration file. cannot continue.") |
| 584 | + wlog.error(format( |
| 585 | + "%d error(s) in configuration file. cannot continue.") |
576 | 586 | % nerrors); |
577 | 587 | exit(8); |
578 | 588 | } |
Index: trunk/willow/src/willow/htcp.cc |
— | — | @@ -41,25 +41,25 @@ |
42 | 42 | if ((len = s->recvfrom(buf, sizeof(buf), addr)) < 1) |
43 | 43 | return; |
44 | 44 | |
45 | | - WDEBUG((WLOG_DEBUG, format("HTCP: received packet from %s, len %d") |
46 | | - % s->straddr() % len)); |
| 45 | + WDEBUG(format("HTCP: received packet from %s, len %d") |
| 46 | + % s->straddr() % len); |
47 | 47 | |
48 | 48 | htcp_decoder ip(buf, len); |
49 | 49 | htcp_encoder op; |
50 | 50 | if (!ip.okay()) { |
51 | 51 | if (ip.major() != 0 || ip.minor() != 1) { |
52 | 52 | /* send an appropriate error */ |
53 | | - WDEBUG((WLOG_DEBUG, format("HTCP: wrong version, %d %d") |
54 | | - % ip.major() % ip.minor())); |
| 53 | + WDEBUG(format("HTCP: wrong version, %d %d") |
| 54 | + % ip.major() % ip.minor()); |
55 | 55 | } else |
56 | 56 | /* packet was too malformed to send an error */ |
57 | | - WDEBUG((WLOG_DEBUG, "HTCP: packet mangled")); |
| 57 | + WDEBUG("HTCP: packet mangled"); |
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | | - WDEBUG((WLOG_DEBUG, |
62 | | - format("HTCP: packet length %d, packet declares length %d and data length %d") |
63 | | - % len % ip.length() % ip.opdata()->length())); |
| 61 | + WDEBUG(format( |
| 62 | + "HTCP: packet length %d, packet declares length %d and data length %d") |
| 63 | + % len % ip.length() % ip.opdata()->length()); |
64 | 64 | |
65 | 65 | /* |
66 | 66 | * If the packet is signed, verify the signature. |
— | — | @@ -67,18 +67,18 @@ |
68 | 68 | if (!ip.keyname().empty()) { |
69 | 69 | map<string,ustring>::iterator it; |
70 | 70 | if ((it = config.htcp_keys.find(ip.keyname())) == config.htcp_keys.end()) { |
71 | | - WDEBUG((WLOG_DEBUG, format("HTCP: unknown key %s") |
72 | | - % ip.keyname())); |
| 71 | + WDEBUG(format("HTCP: unknown key %s") |
| 72 | + % ip.keyname()); |
73 | 73 | return; |
74 | 74 | } |
75 | 75 | |
76 | 76 | if (!ip.verify_signature(ip.keyname(), it->second, |
77 | 77 | addr.addr(), s->address().addr())) { |
78 | | - WDEBUG((WLOG_DEBUG, "HTCP: sig verify failed")); |
| 78 | + WDEBUG("HTCP: sig verify failed"); |
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
82 | | - WDEBUG((WLOG_DEBUG, "HTCP: sig okay")); |
| 82 | + WDEBUG("HTCP: sig okay"); |
83 | 83 | } else if (config.htcp_sigrequired) { |
84 | 84 | return; |
85 | 85 | } |
— | — | @@ -92,7 +92,7 @@ |
93 | 93 | break; |
94 | 94 | |
95 | 95 | htcp_opdata_nop odp; |
96 | | - WDEBUG((WLOG_DEBUG, "HTCP: NOP")); |
| 96 | + WDEBUG("HTCP: NOP"); |
97 | 97 | op.opcode(htcp_op_nop); |
98 | 98 | op.opdata(&odp); |
99 | 99 | op.build_packet(addr.addr(), s->address().addr()); |
— | — | @@ -105,8 +105,8 @@ |
106 | 106 | break; |
107 | 107 | |
108 | 108 | htcp_opdata_tst *opd = (htcp_opdata_tst *)ip.opdata(); |
109 | | - WDEBUG((WLOG_DEBUG, format("HTCP: TST: url=[%s]") |
110 | | - % opd->tst_specifier.hs_url)); |
| 109 | + WDEBUG(format("HTCP: TST: url=[%s]") |
| 110 | + % opd->tst_specifier.hs_url); |
111 | 111 | bool cached = entitycache.cached(opd->tst_specifier.hs_url); |
112 | 112 | htcp_opdata_tst_resp_found tf; |
113 | 113 | htcp_opdata_tst_resp_notfound tnf; |
— | — | @@ -161,7 +161,7 @@ |
162 | 162 | try { |
163 | 163 | alist = addrlist::resolve(hstr, pstr, st_dgram); |
164 | 164 | } catch (socket_error &e) { |
165 | | - wlog(WLOG_WARNING, format("resolving [%s]:%s: %s") |
| 165 | + wlog.warn(format("resolving [%s]:%s: %s") |
166 | 166 | % hstr % pstr % e.what()); |
167 | 167 | return; |
168 | 168 | } |
— | — | @@ -173,8 +173,7 @@ |
174 | 174 | sock = it->makesocket("HTCP listener", prio_stats); |
175 | 175 | sock->nonblocking(true); |
176 | 176 | } catch (socket_error &e) { |
177 | | - wlog(WLOG_WARNING, |
178 | | - format("creating HTCP listener: %s:%s: %s") |
| 177 | + wlog.warn(format("creating HTCP listener: %s:%s: %s") |
179 | 178 | % ip.first % ip.second % e.what()); |
180 | 179 | delete sock; |
181 | 180 | continue; |
— | — | @@ -183,8 +182,7 @@ |
184 | 183 | try { |
185 | 184 | sock->bind(); |
186 | 185 | } catch (socket_error &e) { |
187 | | - wlog(WLOG_WARNING, |
188 | | - format("binding HTCP listener %s: %s") |
| 186 | + wlog.warn(format("binding HTCP listener %s: %s") |
189 | 187 | % it->straddr() % e.what()); |
190 | 188 | delete sock; |
191 | 189 | continue; |
— | — | @@ -195,8 +193,7 @@ |
196 | 194 | |
197 | 195 | sock->readback(polycaller<wsocket *, int>(htcp_handler, |
198 | 196 | &htcp_handler_stru::callback), 0); |
199 | | - wlog(WLOG_NOTICE, format("HTCP listener: %s") |
200 | | - % sock->straddr()); |
| 197 | + wlog.notice(format("HTCP listener: %s") % sock->straddr()); |
201 | 198 | } |
202 | 199 | } |
203 | 200 | |
— | — | @@ -217,7 +214,7 @@ |
218 | 215 | ifn = it->first.substr(i + 1); |
219 | 216 | it->first = it->first.substr(0, i); |
220 | 217 | } |
221 | | - WDEBUG((WLOG_DEBUG, format("HTCP: mcast if: %s") % ifn)); |
| 218 | + WDEBUG(format("HTCP: mcast if: %s") % ifn); |
222 | 219 | add_htcp_listener(*it, ifn); |
223 | 220 | } |
224 | 221 | |
Index: trunk/willow/src/willow/flowio.cc |
— | — | @@ -80,21 +80,21 @@ |
81 | 81 | snprintf(path, sizeof(path), "/dev/shm/willow.diobuf.%d.%d.%d", |
82 | 82 | getpid(), (int) pthread_self(), rand()); |
83 | 83 | if ((_diofd = open(path, O_CREAT | O_EXCL | O_RDWR, 0600)) == -1) { |
84 | | - wlog(WLOG_WARNING, format("opening diobuf %s: %s") |
| 84 | + wlog.warn(format("opening diobuf %s: %s") |
85 | 85 | % path % strerror(errno)); |
86 | 86 | return new char[DIOBUFSZ]; |
87 | 87 | } |
88 | 88 | unlink(path); |
89 | 89 | |
90 | 90 | if (lseek(_diofd, DIOBUFSZ, SEEK_SET) == -1) { |
91 | | - wlog(WLOG_WARNING, format("seeking diobuf %s: %s") |
| 91 | + wlog.warn(format("seeking diobuf %s: %s") |
92 | 92 | % path % strerror(errno)); |
93 | 93 | close(_diofd); |
94 | 94 | _diofd = -1; |
95 | 95 | return new char[DIOBUFSZ]; |
96 | 96 | } |
97 | 97 | if (write(_diofd, "", 1) < 1) { |
98 | | - wlog(WLOG_WARNING, format("extending diobuf %s: %s") |
| 98 | + wlog.warn(format("extending diobuf %s: %s") |
99 | 99 | % path % strerror(errno)); |
100 | 100 | close(_diofd); |
101 | 101 | _diofd = -1; |
— | — | @@ -102,7 +102,7 @@ |
103 | 103 | } |
104 | 104 | ret = (char *)mmap(0, DIOBUFSZ, PROT_READ | PROT_WRITE, MAP_SHARED, _diofd, 0); |
105 | 105 | if (ret == MAP_FAILED) { |
106 | | - wlog(WLOG_WARNING, format("mapping diobuf %s: %s") |
| 106 | + wlog.warn(format("mapping diobuf %s: %s") |
107 | 107 | % path % strerror(errno)); |
108 | 108 | close(_diofd); |
109 | 109 | _diofd = -1; |
— | — | @@ -232,7 +232,7 @@ |
233 | 233 | socket_sink::dio_ready(int fd, off_t off, size_t len, ssize_t &discard) |
234 | 234 | { |
235 | 235 | ssize_t wrote; |
236 | | - WDEBUG((WLOG_DEBUG, format("dio_ready: starting off %d") % off)); |
| 236 | + WDEBUG(format("dio_ready: starting off %d") % off); |
237 | 237 | if ((wrote = _socket->sendfile(fd, &off, len)) == -1) { |
238 | 238 | if (errno == EAGAIN) { |
239 | 239 | _sink_spigot->sp_cork(); |
— | — | @@ -249,8 +249,8 @@ |
250 | 250 | discard += wrote; |
251 | 251 | _counter += wrote; |
252 | 252 | |
253 | | - WDEBUG((WLOG_DEBUG, format("dio_ready: len %d off %d wrote %d fileoff=%d") |
254 | | - % len % off % wrote % lseek(fd, 0, SEEK_CUR))); |
| 253 | + WDEBUG(format("dio_ready: len %d off %d wrote %d fileoff=%d") |
| 254 | + % len % off % wrote % lseek(fd, 0, SEEK_CUR)); |
255 | 255 | |
256 | 256 | if ((ssize_t)len == wrote) { |
257 | 257 | return sink_result_okay; |
— | — | @@ -308,7 +308,7 @@ |
309 | 309 | |
310 | 310 | if (cache) { |
311 | 311 | if (stat(file, &sb) == -1) { |
312 | | - wlog(WLOG_WARNING, format("cannot open %s: %s") |
| 312 | + wlog.warn(format("cannot open %s: %s") |
313 | 313 | % file % strerror(errno)); |
314 | 314 | return false; |
315 | 315 | } |
— | — | @@ -327,7 +327,7 @@ |
328 | 328 | |
329 | 329 | _file.open(file); |
330 | 330 | if (!_file.is_open()) { |
331 | | - wlog(WLOG_WARNING, format("cannot open %s: %s") |
| 331 | + wlog.warn(format("cannot open %s: %s") |
332 | 332 | % file % strerror(errno)); |
333 | 333 | return false; |
334 | 334 | } |
— | — | @@ -349,8 +349,7 @@ |
350 | 350 | |
351 | 351 | _file.open(file); |
352 | 352 | if (!_file.is_open()) |
353 | | - wlog(WLOG_WARNING, format("cannot open %s: %s") |
354 | | - % file % strerror(errno)); |
| 353 | + wlog.warn(format("cannot open %s: %s") % file % strerror(errno)); |
355 | 354 | return _file.is_open(); |
356 | 355 | } |
357 | 356 | |
Index: trunk/willow/willow.conf.example |
— | — | @@ -268,19 +268,17 @@ |
269 | 269 | file = "/var/log/willow/willow.log"; |
270 | 270 | |
271 | 271 | /* |
272 | | - * Log to system. |
273 | | - */ |
274 | | - syslog = yes; |
275 | | - |
276 | | - /* |
277 | | - * Facilities: |
| 272 | + * Log to syslog. |
278 | 273 | * |
279 | | - * user, mail, daemon, auth, lpr, news, uucp, |
280 | | - * cron, audit, local0 .. local7. |
| 274 | + * Available facilities: |
281 | 275 | * |
282 | | - * If not specified, defaults to 'daemon'. |
| 276 | + * user, mail, daemon, auth, lpr, news, uucp, * cron, audit, |
| 277 | + * local0 .. local7; plus some OS-specific ones that you probably |
| 278 | + * con'f want to use. |
| 279 | + * |
| 280 | + * If not specified, syslog is not used. |
283 | 281 | */ |
284 | | - facility = daemon; |
| 282 | + syslog-facility = daemon; |
285 | 283 | |
286 | 284 | /* |
287 | 285 | * Log client requests. Every 1/log-sample requests are logged. |
— | — | @@ -323,7 +321,7 @@ |
324 | 322 | * access blocks, with or without apply-at; they will be merged. |
325 | 323 | */ |
326 | 324 | |
327 | | -access-v4 { |
| 325 | +access { |
328 | 326 | /* allow localhost and the local network */ |
329 | 327 | allow = "127.0.0.1/32", "10.0.0.0/8"; |
330 | 328 | |