5 char *VtServerLog = "libventi/server";
8 #define log not_the_log_library_call
10 static char Eremoved[] = "[removed]";
30 for(p=(uchar*)s; *p; p++)
45 for(i=0; i<nelem(vl.hash); i++)
46 for(l=vl.hash[i]; l; l=l->next){
48 size += strlen(l->name)+1;
51 s = vtmalloc(nname*sizeof(char*)+size);
53 e = (char*)s+nname*sizeof(char*)+size;
56 for(i=0; i<nelem(vl.hash); i++)
57 for(l=vl.hash[i]; l; l=l->next){
70 vtlogopen(char *name, uint size)
80 h = hash(name)%nelem(vl.hash);
83 for(l=vl.hash[h]; l; last=l, l=l->next)
84 if(strcmp(l->name, name) == 0){
85 if(last){ /* move to front */
101 nc = (size+LogChunkSize-1)/LogChunkSize;
102 l = vtmalloc(sizeof *l + nc*(sizeof(*l->chunk)+LogChunkSize) + strlen(name)+1);
103 memset(l, 0, sizeof *l);
104 l->chunk = (VtLogChunk*)(l+1);
107 p = (char*)(l->chunk+nc);
118 l->next = vl.hash[h];
135 /* must not be in hash table */
136 assert(l->name == Eremoved);
144 vtlogremove(char *name)
149 h = hash(name)%nelem(vl.hash);
152 for(l=vl.hash[h]; l; last=l, l=l->next)
153 if(strcmp(l->name, name) == 0){
155 last->next = l->next;
157 vl.hash[h] = l->next;
176 return fmtprint(fmt, "T+%d.%04d", (uint)(t/1000000000), (uint)(t%1000000000)/100000);
180 vtlogvprint(VtLog *l, char *fmt, va_list arg)
185 static int first = 1;
191 fmtinstall('T', timefmt);
201 if(c == l->chunk+l->nchunk)
206 p = vseprint(c->wp, c->ep, fmt, arg);
213 vtlogprint(VtLog *l, char *fmt, ...)
221 vtlogvprint(l, fmt, arg);
226 vtlog(char *name, char *fmt, ...)
231 l = vtlogopen(name, LogSize);
235 vtlogvprint(l, fmt, arg);
241 vtlogdump(int fd, VtLog *l)
250 for(i=0; i<l->nchunk; i++){
251 if(++c == l->chunk+l->nchunk)
253 write(fd, c->p, c->wp-c->p);