Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 03056c7

Browse files
committed
Disable logging to file in agent
1 parent 0df77d0 commit 03056c7

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/utils/file.c

+11-3
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,23 @@ FILE* fio_fopen(char const* path, char const* mode, fio_location location)
268268
FILE* f;
269269
if (fio_is_remote(location))
270270
{
271-
int flags = O_RDWR|O_CREAT|PG_BINARY|(strchr(mode, '+') ? 0 : O_TRUNC);
272-
int fd = fio_open(path, flags, location);
271+
int flags = O_RDWR|O_CREAT;
272+
int fd;
273+
if (strcmp(mode, PG_BINARY_W) == 0) {
274+
flags |= O_TRUNC|PG_BINARY;
275+
} else if (strncmp(mode, PG_BINARY_R, strlen(PG_BINARY_R)) == 0) {
276+
flags |= PG_BINARY;
277+
} else if (strcmp(mode, "a") == 0) {
278+
flags |= O_APPEND;
279+
}
280+
fd = fio_open(path, flags, location);
273281
f = (FILE*)(size_t)((fd + 1) & ~FIO_PIPE_MARKER);
274282
}
275283
else
276284
{
277285
f = fopen(path, mode);
278286
if (f == NULL && strcmp(mode, PG_BINARY_R "+") == 0)
279-
f = fopen(path, PG_BINARY_W);
287+
f = fopen(path, PG_BINARY_W);
280288
}
281289
return f;
282290
}

src/utils/logger.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,10 @@ elog_internal(int elevel, bool file_only, const char *message)
157157
time_t log_time = (time_t) time(NULL);
158158
char strfbuf[128];
159159

160-
write_to_file = elevel >= logger_config.log_level_file &&
161-
logger_config.log_directory && logger_config.log_directory[0] != '\0';
160+
write_to_file = elevel >= logger_config.log_level_file
161+
&& logger_config.log_directory
162+
&& logger_config.log_directory[0] != '\0'
163+
&& !remote_agent;
162164
write_to_error_log = elevel >= ERROR && logger_config.error_log_filename &&
163165
logger_config.log_directory && logger_config.log_directory[0] != '\0';
164166
write_to_stderr = elevel >= (remote_agent ? ERROR : logger_config.log_level_console) && !file_only;

0 commit comments

Comments
 (0)