Browse Source

Add a new debug function

Yann Weber 7 years ago
parent
commit
aa31c07bf1
2 changed files with 30 additions and 1 deletions
  1. 1
    0
      src/include/ttail_search.h
  2. 29
    1
      src/ttail_search.c

+ 1
- 0
src/include/ttail_search.h View File

@@ -114,5 +114,6 @@ void ttail_tm_init(struct tm* tm);
114 114
  *@param struct tm *
115 115
  */
116 116
 void ttail_tm_print(const struct tm*);
117
+void ttail_tm_fprint(FILE*, const struct tm*);
117 118
 
118 119
 #endif

+ 29
- 1
src/ttail_search.c View File

@@ -113,7 +113,7 @@ const char* ttail_logline_subst(ttail_t* t, const char* logline)
113 113
 	}
114 114
 	/* regex subst */
115 115
 	nmatch=1;
116
-	ret = regexec(&(t->date_prefix), logline, nmatch, pmatch, 0);\
116
+	ret = regexec(&(t->date_prefix), logline, nmatch, pmatch, 0);
117 117
 	if(ret)
118 118
 	{
119 119
 		regerror(ret, &(t->date_prefix), err,1024);
@@ -178,3 +178,31 @@ void ttail_tm_print(const struct tm* tm)
178 178
 		tm->tm_sec);
179 179
 }
180 180
 
181
+void ttail_tm_fprint(FILE *stream, const struct tm* tm)
182
+{
183
+	if(tm->tm_year >= 0)
184
+	{
185
+		fprintf(stream, "year : %d ", tm->tm_year + 1900);
186
+	}
187
+	if(tm->tm_mon >= 0)
188
+	{
189
+		fprintf(stream, "month : %d ", tm->tm_mon);
190
+	}
191
+	if(tm->tm_mday >= 0)
192
+	{
193
+		fprintf(stream, "day : %d ", tm->tm_mday);
194
+	}
195
+	if(tm->tm_hour >= 0)
196
+	{
197
+		fprintf(stream, "hour : %d ", tm->tm_hour);
198
+	}
199
+	if(tm->tm_min >= 0)
200
+	{
201
+		fprintf(stream, "minute : %d ", tm->tm_min);
202
+	}
203
+	if(tm->tm_sec >= 0)
204
+	{
205
+		fprintf(stream, "secs : %d ", tm->tm_sec);
206
+	}
207
+}
208
+

Loading…
Cancel
Save