Skip to content

Commit

Permalink
Fixed grep -ai & grep -aic
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeke committed Sep 19, 2017
1 parent 8a8c9ce commit 2c267ec
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
3 changes: 3 additions & 0 deletions include/SeasLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@
#define SEASLOG_GENERATE_LOG_INFO 2
#define SEASLOG_GENERATE_SYSLOG_INFO 3

#define SEASLOG_ANALYZER_DEFAULT_START 1
#define SEASLOG_ANALYZER_DEFAULT_OFFSET 20

#define SEASLOG_GLOBAL_VARS_SERVER TRACK_VARS_SERVER

#if PHP_VERSION_ID >= 70000
Expand Down
22 changes: 16 additions & 6 deletions src/Analyzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ static long get_type_count(char *log_path, char *level, char *key_word TSRMLS_DC
#else
if (is_level_all == 1)
{
spprintf(&sh, 0, "cat %s 2>/dev/null| grep '%s' -ac", path, key_word);
spprintf(&sh, 0, "cat %s 2>/dev/null| grep '%s' -aic", path, key_word);
}
else
{
spprintf(&sh, 0, "cat %s 2>/dev/null| grep -a '%s' | grep '%s' -ac", path, level, key_word);
spprintf(&sh, 0, "cat %s 2>/dev/null| grep -ai '%s' | grep '%s' -aic", path, level, key_word);
}
#endif
}
Expand All @@ -78,7 +78,7 @@ static long get_type_count(char *log_path, char *level, char *key_word TSRMLS_DC
}
else
{
spprintf(&sh, 0, "cat %s 2>/dev/null| grep '%s' -ac", path, level);
spprintf(&sh, 0, "cat %s 2>/dev/null| grep '%s' -aic", path, level);
}
#endif
}
Expand Down Expand Up @@ -116,6 +116,16 @@ static int get_detail(char *log_path, char *level, char *key_word, long start, l

array_init(return_value);

if (start < 0)
{
start = SEASLOG_ANALYZER_DEFAULT_START;
}

if (end < 0)
{
end = SEASLOG_ANALYZER_DEFAULT_OFFSET;
}

if (!strcmp(level, SEASLOG_ALL))
{
is_level_all = 1;
Expand Down Expand Up @@ -157,11 +167,11 @@ static int get_detail(char *log_path, char *level, char *key_word, long start, l
#else
if (is_level_all == 1)
{
spprintf(&sh, 0, "%s 2>/dev/null| grep -a '%s' | sed -n '%ld,%ld'p", command, key_word, start, end);
spprintf(&sh, 0, "%s 2>/dev/null| grep -ai '%s' | sed -n '%ld,%ld'p", command, key_word, start, end);
}
else
{
spprintf(&sh, 0, "%s 2>/dev/null| grep -a '%s' | grep -a '%s' | sed -n '%ld,%ld'p", command, level, key_word, start, end);
spprintf(&sh, 0, "%s 2>/dev/null| grep -ai '%s' | grep -ai '%s' | sed -n '%ld,%ld'p", command, level, key_word, start, end);
}
#endif
}
Expand All @@ -176,7 +186,7 @@ static int get_detail(char *log_path, char *level, char *key_word, long start, l
}
else
{
spprintf(&sh, 0, "%s 2>/dev/null| grep -a '%s' | sed -n '%ld,%ld'p", command, level, start, end);
spprintf(&sh, 0, "%s 2>/dev/null| grep -ai '%s' | sed -n '%ld,%ld'p", command, level, start, end);
}
#endif
}
Expand Down

0 comments on commit 2c267ec

Please sign in to comment.