Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4e3e62b

Browse files
committed
Fix problem with logging
1 parent85b247d commit4e3e62b

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

‎src/utils/logger.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ exit_if_necessary(int elevel)
131131
pthread_mutex_unlock(&log_file_mutex);
132132
}
133133

134+
if (remote_agent)
135+
sleep(1);/* Let parent receive sent messages */
136+
134137
/* If this is not the main thread then don't call exit() */
135138
if (main_tid!=pthread_self())
136139
#ifdefWIN32

‎src/utils/remote.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,20 @@ static void kill_child(void)
7979
kill(child_pid,SIGTERM);
8080
}
8181

82+
83+
staticvoidprint_message(charconst*buf)
84+
{
85+
charconst*constseverity[]= {"VERBOSE","LOG","INFO","NOTICE","WARNING","FATAL","ERROR",""};
86+
size_ti;
87+
for (i=0;strncmp(buf,severity[i],strlen(severity[i]))!=0;i++);
88+
elog(i+VERBOSE,"%s",buf+strlen(severity[i])+2);
89+
}
90+
8291
staticvoid*error_reader_proc(void*arg)
8392
{
8493
int*errfd= (int*)arg;
8594
charbuf[ERR_BUF_SIZE];
8695
intoffs=0,rc;
87-
8896
while ((rc=read(errfd[0],&buf[offs],sizeof(buf)-offs))>0)
8997
{
9098
char*nl;
@@ -93,22 +101,15 @@ static void* error_reader_proc(void* arg)
93101
nl=strchr(buf,'\n');
94102
if (nl!=NULL) {
95103
*nl='\0';
96-
if (strncmp(buf,"ERROR: ",7)==0) {
97-
elog(ERROR,"%s",buf+7);
98-
}if (strncmp(buf,"WARNING: ",9)==0) {
99-
elog(WARNING,"%s",buf+9);
100-
}if (strncmp(buf,"VERBOSE: ",9)==0) {
101-
elog(VERBOSE,"%s",buf+9);
102-
}elseif (strncmp(buf,"LOG: ",5)==0) {
103-
elog(LOG,"%s",buf+5);
104-
}elseif (strncmp(buf,"INFO: ",6)==0) {
105-
elog(INFO,"%s",buf+6);
106-
}else {
107-
elog(LOG,"%s",buf);
108-
}
104+
print_message(buf);
109105
memmove(buf,nl+1,offs-= (nl+1-buf));
110106
}
111107
}
108+
if (offs!=0)
109+
{
110+
buf[offs]='\0';
111+
print_message(buf);
112+
}
112113
returnNULL;
113114
}
114115

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp