Skip to content
This repository has been archived by the owner on Mar 12, 2019. It is now read-only.

Commit

Permalink
Merge pull request #107 from PierreF/quiet-log
Browse files Browse the repository at this point in the history
Quiet log
  • Loading branch information
jpmens committed Oct 29, 2015
2 parents 4f6dca0 + f74da73 commit 4d4f738
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Options therein with a leading ```auth_opt_``` are handed to the plugin. The fol
| -------------- | ---------- | :---------: | --------------------- |
| backends | | Y | comma-separated list of back-ends to load |
| superusers | | | fnmatch(3) case-sensitive string
| log_quiet | false | | don't log DEBUG messages |

Individual back-ends have their options described in the sections below.

Expand Down
9 changes: 9 additions & 0 deletions auth-plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ int mosquitto_auth_plugin_init(void **userdata, struct mosquitto_auth_opt *auth_
}
if (!strcmp(o->key, "cacheseconds"))
ud->cacheseconds = atol(o->value);
if (!strcmp(o->key, "log_quiet")) {
if(!strcmp(o->value, "false") || !strcmp(o->value, "0")){
log_quiet = 0;
}else if(!strcmp(o->value, "true") || !strcmp(o->value, "1")){
log_quiet = 1;
}else{
_log(LOG_NOTICE, "Error: Invalid log_quiet value (%s).", o->value);
}
}
#if 0
if (!strcmp(o->key, "topic_prefix"))
ud->topicprefix = strdup(o->value);
Expand Down
4 changes: 4 additions & 0 deletions log.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@
#include <time.h>
#include "log.h"

int log_quiet=0;

void _log(int priority, const char *fmt, ...)
{
va_list va;
time_t now;

if (log_quiet && priority <= LOG_DEBUG)
return;

/* FIXME: use new log function when @ralight is ready */
/* interim solution - link with -rdynamic then #include <mosquitto_broker.h> and use _mosquitto_log_printf(). */
Expand Down
2 changes: 2 additions & 0 deletions log.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@

void _log(int priority, const char *fmt, ...);
void _fatal(const char *fmt, ...);

extern int log_quiet;

0 comments on commit 4d4f738

Please sign in to comment.