diff --git a/Documentation/Getting-Started/Configuration-Guide.md b/Documentation/Getting-Started/Configuration-Guide.md index 01a8c1dba..0bb10617b 100644 --- a/Documentation/Getting-Started/Configuration-Guide.md +++ b/Documentation/Getting-Started/Configuration-Guide.md @@ -124,6 +124,18 @@ log_debug=1 To disable the log use the value 0 and to enable it use the value 1. +#### `log_augmentation` + +Enable or disable the augmentation of messages. If this is enabled, then each logged message is appended with the name of the function where the message was logged. This is primarily for development purposes and hence is disabled by default. + +``` +# Valid options are: +# log_augmentation=<0|1> +log_augmentation=1 +``` + +To disable the augmentation use the value 0 and to enable it use the value 1. + #### `logdir` Set the directory where the logfiles are stored. The folder needs to be both readable and writable by the user running MaxScale. diff --git a/Documentation/Tutorials/Administration-Tutorial.md b/Documentation/Tutorials/Administration-Tutorial.md index 364ca7e41..920c60f96 100644 --- a/Documentation/Tutorials/Administration-Tutorial.md +++ b/Documentation/Tutorials/Administration-Tutorial.md @@ -43,6 +43,7 @@ Switch|Long Option|Description `-U USER`|`--user=USER`|run MaxScale as another user. The user ID and group ID of this user are used to run MaxScale. `-s [yes no]`|`--syslog=[yes no]`|log messages to syslog (default:yes) `-S [yes no]`|`--maxscalelog=[yes no]`|log messages to MaxScale log (default: yes) +`-G [0 1]`|`--log_augmentation=[0 1]`|augment messages with the name of the function where the message was logged (default: 0). Primarily for development purposes. `-v`|`--version`|print version info and exit `-V`|`--version-full`|print version info and the commit ID the binary was built from `-?`|`--help`|show this help diff --git a/log_manager/log_manager.cc b/log_manager/log_manager.cc index c5c1f7bd6..4dc77f619 100644 --- a/log_manager/log_manager.cc +++ b/log_manager/log_manager.cc @@ -106,7 +106,7 @@ static bool flushall_done_flag; /** * Default augmentation. */ -static int default_log_augmentation = LOG_AUGMENT_WITH_FUNCTION; +static int default_log_augmentation = 0; static int log_augmentation = default_log_augmentation; /** Writer thread structure */ diff --git a/server/core/gateway.c b/server/core/gateway.c index 32c11584f..5a7b6f500 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -181,6 +181,7 @@ static struct option long_options[] = { {"version", no_argument, 0, 'v'}, {"help", no_argument, 0, '?'}, {"version-full", no_argument, 0, 'V'}, + {"log_augmentation", required_argument, 0, 'G'}, {0, 0, 0, 0} }; static int cnf_preparser(void* data, const char* section, const char* name, const char* value); @@ -197,6 +198,7 @@ static int ntfw_cb(const char*, const struct stat*, int, struct FTW*); static bool file_is_readable(char* absolute_pathname); static bool file_is_writable(char* absolute_pathname); bool handle_path_arg(char** dest, char* path, char* arg, bool rd, bool wr); +static void set_log_augmentation(const char* value); static void usage(void); static char* get_expanded_pathname( char** abs_path, @@ -1128,7 +1130,7 @@ int main(int argc, char **argv) } } - while ((opt = getopt_long(argc, argv, "dc:f:l:vVs:S:?L:D:C:B:U:A:P:", + while ((opt = getopt_long(argc, argv, "dc:f:l:vVs:S:?L:D:C:B:U:A:P:G:", long_options, &option_index)) != -1) { bool succp = true; @@ -1291,6 +1293,9 @@ int main(int argc, char **argv) succp = false; } break; + case 'G': + set_log_augmentation(optarg); + break; case '?': usage(); rc = EXIT_SUCCESS; @@ -2312,6 +2317,21 @@ bool handle_path_arg(char** dest, char* path, char* arg, bool rd, bool wr) return rval; } +void set_log_augmentation(const char* value) +{ + // Command line arguments are handled first, thus command line argument + // has priority. + + static bool augmentation_set = false; + + if (!augmentation_set) + { + skygw_log_set_augmentation(atoi(value)); + + augmentation_set = true; + } +} + /** * Pre-parse the MaxScale.cnf for config, log and module directories. * @param data Parameter passed by inih @@ -2423,6 +2443,10 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons { cnf->maxlog = config_truth_value((char*)value); } + else if(strcmp(name, "log_augmentation") == 0) + { + set_log_augmentation(value); + } } return 1;