out_file: use new output logging api
* limitations under the License.
*/
+#include <fluent-bit/flb_output_plugin.h>
#include <fluent-bit/flb_mem.h>
-#include <fluent-bit/flb_output.h>
#include <fluent-bit/flb_pack.h>
#include <fluent-bit/flb_utils.h>
#include <fluent-bit/flb_time.h>
@@ -44,6 +44,7 @@ struct flb_file_conf {
const char *label_delimiter;
const char *template;
int format;
+ struct flb_output_instance *ins;
};
static char *check_delimiter(const char *str)
@@ -82,7 +83,7 @@ static int cb_file_init(struct flb_output_instance *ins,
flb_errno();
return -1;
}
-
+ ctx->ins = ins;
ctx->format = FLB_OUT_FILE_FMT_JSON; /* default */
ctx->delimiter = NULL;
ctx->label_delimiter = NULL;
@@ -193,7 +194,8 @@ static int ltsv_output(FILE *fp, struct flb_time *tm, msgpack_object *obj,
return 0;
}
-static int template_output_write(FILE *fp, struct flb_time *tm, msgpack_object *obj,
+static int template_output_write(struct flb_file_conf *ctx,
+ FILE *fp, struct flb_time *tm, msgpack_object *obj,
const char *key, int size)
{
int i;
@@ -209,7 +211,7 @@ static int template_output_write(FILE *fp, struct flb_time *tm, msgpack_object *
}
if (obj->type != MSGPACK_OBJECT_MAP) {
- flb_error("[out_file] invalid object type (type=%i)", obj->type);
+ flb_plg_error(ctx->ins, "invalid object type (type=%i)", obj->type);
return -1;
}
@@ -267,7 +269,7 @@ static int template_output(FILE *fp, struct flb_time *tm, msgpack_object *obj,
key = inbrace + 1;
keysize = pos - inbrace - 1;
- if (template_output_write(fp, tm, obj, key, keysize)) {
+ if (template_output_write(ctx, fp, tm, obj, key, keysize)) {
fwrite(inbrace, 1, pos - inbrace + 1, fp);
}
inbrace = NULL;
