Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev log improvements #301

Merged
merged 5 commits into from
Jun 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fusedav-statsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static int stats_send(const char *statmsg) {
if (bytes == -1) {
// Since the is UDP, sendto can't know if the message was never delivered. Error means local error that
// it can detect.
log_print(LOG_CRIT, SECTION_STATS_DEFAULT, "stats_send: Error, errno: %d, %s. Couldn't send stat \"%s\"",
log_print(LOG_NOTICE, SECTION_STATS_DEFAULT, "stats_send: Error, errno: %d, %s. Couldn't send stat \"%s\"",
errno, strerror(errno), statmsg);
} else if (bytes < statmsglen) {
log_print(LOG_CRIT, SECTION_STATS_DEFAULT, "stats_send: sendto error: expected %d bytes; got %d", statmsglen, bytes);
Expand Down
2 changes: 1 addition & 1 deletion src/fusedav.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static int simple_propfind_with_redirect(
stats_counter("propfind-count", 1);
stats_timer("propfind-latency", elapsed_time);
if (elapsed_time > propfind_time_allotment) {
log_print(LOG_DEBUG, SECTION_FUSEDAV_STAT, "simple_propfind_with_redirect: (%s) PROPFIND exceeded allotment of %u ms; took %u ms.",
log_print(LOG_WARNING, SECTION_FUSEDAV_STAT, "simple_propfind_with_redirect: (%s) PROPFIND exceeded allotment of %u ms; took %u ms.",
last_updated > 0 ? "progressive" : "complete", propfind_time_allotment, elapsed_time);
stats_counter("exceeded-time-propfind-count", 1);
stats_timer("exceeded-time-propfind-latency", elapsed_time);
Expand Down
24 changes: 12 additions & 12 deletions src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ __thread unsigned int LOG_DYNAMIC = LOG_INFO;
// Store values for loggging in the log_key_value array, which is set in fusedav_config.
#define USER_AGENT_ABBREV 0
#define BASEURL_FIRST 1
#define BASEURL_SECOND 2
#define HOST_ADDRESS 2
#define BASEURL_THIRD 3
#define BASEURL_FOURTH 4
#define SITE 4
#define BASEURL_FIFTH 5
#define BASEURL_SIXTH 6
#define ENVIRONMENT 6
#define BASEURL_SEVENTH 7
#define BASEURL_EIGHTH 8
// last item plus one
Expand Down Expand Up @@ -173,9 +173,9 @@ static int print_it(const char const *formatwithtid, const char const *msg, int
ret = sd_journal_send("MESSAGE=%s%s", formatwithtid, msg,
"PRIORITY=%d", log_level,
"USER_AGENT=%s", get_user_agent(),
"SITE=%s", log_key_value[BASEURL_FOURTH],
"ENVIRONMENT=%s", log_key_value[BASEURL_SIXTH],
"HOST_ADDRESS=%s", log_key_value[BASEURL_SECOND],
"SITE=%s", log_key_value[SITE],
"ENVIRONMENT=%s", log_key_value[ENVIRONMENT],
"HOST_ADDRESS=%s", log_key_value[HOST_ADDRESS],
"TID=%lu", syscall(SYS_gettid),
"PACKAGE_VERSION=%s", PACKAGE_VERSION,
NULL);
Expand All @@ -187,24 +187,24 @@ int log_print(unsigned int log_level, unsigned int section, const char *format,
int ret = 0;
if (logging(log_level, section)) {
va_list ap;
char *formatwithtid;
char *formatwithlevel;
char msg[max_msg_sz + 1];

va_start(ap, format);
vsnprintf(msg, max_msg_sz, format, ap);
asprintf(&formatwithtid, "[tid=%lu] [bid=%s] %s", syscall(SYS_gettid), log_key_value[USER_AGENT_ABBREV], errlevel[log_level]);
assert(formatwithtid);
asprintf(&formatwithlevel, "%s", errlevel[log_level]);
assert(formatwithlevel);

// print the intended message
ret = print_it(formatwithtid, msg, log_level);
ret = print_it(formatwithlevel, msg, log_level);

// Check and see if we're no longer doing dynamic logging. If so, it will take effect after this call. Then print a message
if (turning_off_dynamic_logging()) {
strcpy(msg, "revert_dynamic_logging");
print_it(formatwithtid, msg, log_level);
print_it(formatwithlevel, msg, log_level);
}

free(formatwithtid);
free(formatwithlevel);
va_end(ap);
}

Expand Down