Esempio n. 1
0
static void
log4g_file_appender_class_init(Log4gFileAppenderClass *klass)
{
	GObjectClass *object_class = G_OBJECT_CLASS(klass);
	object_class->finalize = finalize;
	object_class->set_property = set_property;
	Log4gAppenderClass *appender_class = LOG4G_APPENDER_CLASS(klass);
	appender_class->activate_options = activate_options;
	Log4gWriterAppenderClass *writer_class =
		LOG4G_WRITER_APPENDER_CLASS(klass);
	writer_class->reset = reset;
	klass->set_file_full = set_file_full;
	klass->set_qw_for_files = set_qw_for_files;
	g_type_class_add_private(klass, sizeof(struct Private));
	/* install properties */
	g_object_class_install_property(object_class, PROP_FILE,
		g_param_spec_string("file", Q_("File"),
			Q_("Output file name"), NULL, G_PARAM_WRITABLE));
	g_object_class_install_property(object_class, PROP_APPEND,
		g_param_spec_boolean("append", Q_("Append"),
			Q_("Append or overwrite file"), TRUE,
			G_PARAM_WRITABLE));
	g_object_class_install_property(object_class, PROP_BUFFERED_IO,
		g_param_spec_boolean("buffered-io", Q_("Buffered I/O"),
			Q_("Buffer log output"), FALSE, G_PARAM_WRITABLE));
	g_object_class_install_property(object_class, PROP_BUFFER_SIZE,
		g_param_spec_uint("buffer-size", Q_("Buffer Size"),
			Q_("Size of the output buffer"),
			0, G_MAXUINT, 8 * 1024, G_PARAM_WRITABLE));
}
Esempio n. 2
0
static void
log4g_rolling_file_appender_class_init(Log4gRollingFileAppenderClass *klass)
{
	GObjectClass *object_class = G_OBJECT_CLASS(klass);
	object_class->set_property = set_property;
	Log4gWriterAppenderClass *writer_class =
		LOG4G_WRITER_APPENDER_CLASS(klass);
	writer_class->sub_append = sub_append;
	Log4gFileAppenderClass *file_class =
		LOG4G_FILE_APPENDER_CLASS(klass);
	file_class->set_file_full = set_file_full;
	file_class->set_qw_for_files = set_qw_for_files;
	klass->roll_over = roll_over;
	g_type_class_add_private(klass, sizeof(struct Private));
	/* install properties */
	g_object_class_install_property(object_class, PROP_MAX_BACKUP_INDEX,
		g_param_spec_uint("max-backup-index",
			Q_("Maximum Backup Index"),
			Q_("Maximum number of backup files"),
			0, G_MAXUINT, 1, G_PARAM_WRITABLE));
	g_object_class_install_property(object_class, PROP_MAXIMUM_FILE_SIZE,
		g_param_spec_ulong("maximum-file-size",
			Q_("Maximum File Size"),
			Q_("Maximum size a log file may grow to"),
			0, G_MAXULONG, 10 * 1024 * 1024, G_PARAM_WRITABLE));
}
Esempio n. 3
0
static void
reset(Log4gAppender *base)
{
	struct Private *priv = GET_PRIVATE(base);
	log4g_file_appender_close_file(base);
	g_free(priv->file);
	priv->file = NULL;
	LOG4G_WRITER_APPENDER_CLASS(log4g_file_appender_parent_class)->
		reset(base);
}
Esempio n. 4
0
static void
sub_append(Log4gAppender *base, Log4gLoggingEvent *event)
{
	struct Private *priv = GET_PRIVATE(base);
	Log4gQuietWriter *writer =
		log4g_writer_appender_get_quiet_writer(base);
	LOG4G_WRITER_APPENDER_CLASS(log4g_rolling_file_appender_parent_class)->
		sub_append(base, event);
	if (log4g_file_appender_get_file(base) && writer) {
		gulong size = log4g_counting_quiet_writer_get_count(writer);
		if ((size >= priv->max) && (size >= priv->next)) {
			log4g_rolling_file_appender_roll_over(base);
		}
	}
}