diff options
author | diosmosis <benaka@piwik.pro> | 2015-01-22 06:53:24 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-01-22 06:53:48 +0300 |
commit | 9ed81d72cbaa1ebe382502d9417d7d1ac64dab00 (patch) | |
tree | 76bc56768c42f4366dbb8a1233f36353436f5ec1 /misc | |
parent | ed3cebf7583ab53433e10091aa78658eaefad08e (diff) |
Add --dump-log-regex option to log importer for debugging purposes. Using the option forces the log importer to print out the regex used to parse log lines and exit.
Diffstat (limited to 'misc')
-rwxr-xr-x | misc/log-analytics/import_logs.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/misc/log-analytics/import_logs.py b/misc/log-analytics/import_logs.py index 5d663feb0f..a3036dde56 100755 --- a/misc/log-analytics/import_logs.py +++ b/misc/log-analytics/import_logs.py @@ -606,6 +606,12 @@ class Configuration(object): "changed General.action_title_category_delimiter in your Piwik configuration, you need to set this " "option to the same value in order to get a pretty page titles report." ) + option_parser.add_option( + '--dump-log-regex', dest='dump_log_regex', action='store_true', default=False, + help="Prints out the regex string used to parse log lines and exists. Can be useful for using formats " + "in newer versions of the script in older versions of the script. The output regex can be used with " + "the --log-format-regex option." + ) return option_parser def _set_w3c_field_map(self, option, opt_str, value, parser): @@ -1732,6 +1738,15 @@ class Parser(object): # Make sure the format is compatible with the resolver. resolver.check_format(format) + if config.options.dump_log_regex: + logging.info("Using format '%s'." % format.name) + if format.regex: + logging.info("Regex being used: %s" % format.regex.pattern) + else: + logging.info("Format %s does not use a regex to parse log lines." % format.name) + logging.info("--dump-log-regex option used, aborting log import.") + os._exit(0) + hits = [] for lineno, line in enumerate(file): try: |