Esempio n. 1
0
LogDriver *
afamqp_dd_new(void)
{
  AMQPDestDriver *self = g_new0(AMQPDestDriver, 1);

  log_dest_driver_init_instance(&self->super);
  self->super.super.super.init = afamqp_dd_init;
  self->super.super.super.deinit = afamqp_dd_deinit;
  self->super.super.super.queue = afamqp_dd_queue;
  self->super.super.super.free_fn = afamqp_dd_free;

  self->routing_key_template = log_template_new(configuration, NULL);

  afamqp_dd_set_vhost((LogDriver *) self, "/");
  afamqp_dd_set_host((LogDriver *) self, "127.0.0.1");
  afamqp_dd_set_port((LogDriver *) self, 5672);
  afamqp_dd_set_exchange((LogDriver *) self, "syslog");
  afamqp_dd_set_exchange_type((LogDriver *) self, "fanout");
  afamqp_dd_set_routing_key((LogDriver *) self, "");
  afamqp_dd_set_persistent((LogDriver *) self, TRUE);
  afamqp_dd_set_exchange_declare((LogDriver *) self, FALSE);

  init_sequence_number(&self->seq_num);

  self->writer_thread_wakeup_cond = g_cond_new();
  self->suspend_mutex = g_mutex_new();
  self->queue_mutex = g_mutex_new();

  self->max_entries = 256;
  self->entries = g_new(amqp_table_entry_t, self->max_entries);

  return (LogDriver *) self;
}
Esempio n. 2
0
LogDriver *
afamqp_dd_new(GlobalConfig *cfg)
{
    AMQPDestDriver *self = g_new0(AMQPDestDriver, 1);

    log_threaded_dest_driver_init_instance(&self->super);

    self->super.super.super.super.init = afamqp_dd_init;
    self->super.super.super.super.free_fn = afamqp_dd_free;

    self->super.worker.thread_init = afamqp_worker_thread_init;
    self->super.worker.disconnect = afamqp_dd_disconnect;
    self->super.worker.insert = afamqp_worker_insert;

    self->super.format.stats_instance = afamqp_dd_format_stats_instance;
    self->super.format.persist_name = afamqp_dd_format_persist_name;
    self->super.stats_source = SCS_AMQP;

    self->routing_key_template = log_template_new(cfg, NULL);

    afamqp_dd_set_vhost((LogDriver *) self, "/");
    afamqp_dd_set_host((LogDriver *) self, "127.0.0.1");
    afamqp_dd_set_port((LogDriver *) self, 5672);
    afamqp_dd_set_exchange((LogDriver *) self, "syslog");
    afamqp_dd_set_exchange_type((LogDriver *) self, "fanout");
    afamqp_dd_set_routing_key((LogDriver *) self, "");
    afamqp_dd_set_persistent((LogDriver *) self, TRUE);
    afamqp_dd_set_exchange_declare((LogDriver *) self, FALSE);

    init_sequence_number(&self->seq_num);

    self->max_entries = 256;
    self->entries = g_new(amqp_table_entry_t, self->max_entries);

    log_template_options_defaults(&self->template_options);
    afamqp_dd_set_value_pairs(&self->super.super.super, value_pairs_new_default(cfg));

    return (LogDriver *) self;
}