/* Debug.c generated by valac 0.40.4, the Vala compiler
 * generated from Debug.vala, do not modify */

/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU LGPL (version 2.1 or later).
 * See the COPYING file in this distribution.
 */


#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <gio/gio.h>
#include <glib/gstdio.h>
#include <time.h>
#include <unistd.h>

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _fclose0(var) ((var == NULL) ? NULL : (var = (fclose (var), NULL)))


extern GLogLevelFlags debug_log_mask;
GLogLevelFlags debug_log_mask = 0;
extern gchar* debug_log_app_version_prefix;
gchar* debug_log_app_version_prefix = NULL;
extern FILE* debug_log_out;
FILE* debug_log_out = NULL;
extern FILE* debug_log_err;
FILE* debug_log_err = NULL;
extern FILE* debug_log_file_stream;
FILE* debug_log_file_stream = NULL;

#define DEBUG_DEFAULT_LOG_MASK ((G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING) | G_LOG_LEVEL_MESSAGE)
#define DEBUG_VIEWER_PREFIX "V"
#define DEBUG_LIBRARY_PREFIX "L"
void debug_init (const gchar* app_version_prefix);
GFile* app_dirs_get_log_file (void);
void debug_info_handler (const gchar* domain,
                         GLogLevelFlags flags,
                         const gchar* message);
static void _debug_info_handler_glog_func (const gchar* log_domain,
                                    GLogLevelFlags log_levels,
                                    const gchar* message,
                                    gpointer self);
void debug_debug_handler (const gchar* domain,
                          GLogLevelFlags flags,
                          const gchar* message);
static void _debug_debug_handler_glog_func (const gchar* log_domain,
                                     GLogLevelFlags log_levels,
                                     const gchar* message,
                                     gpointer self);
void debug_message_handler (const gchar* domain,
                            GLogLevelFlags flags,
                            const gchar* message);
static void _debug_message_handler_glog_func (const gchar* log_domain,
                                       GLogLevelFlags log_levels,
                                       const gchar* message,
                                       gpointer self);
void debug_warning_handler (const gchar* domain,
                            GLogLevelFlags flags,
                            const gchar* message);
static void _debug_warning_handler_glog_func (const gchar* log_domain,
                                       GLogLevelFlags log_levels,
                                       const gchar* message,
                                       gpointer self);
void debug_critical_handler (const gchar* domain,
                             GLogLevelFlags flags,
                             const gchar* message);
static void _debug_critical_handler_glog_func (const gchar* log_domain,
                                        GLogLevelFlags log_levels,
                                        const gchar* message,
                                        gpointer self);
void debug_terminate (void);
gboolean debug_is_enabled (GLogLevelFlags flag);
void debug_log (FILE* stream,
                const gchar* prefix,
                const gchar* message);


static gpointer
_g_object_ref0 (gpointer self)
{
#line 37 "/home/jens/Source/shotwell/src/Debug.vala"
	return self ? g_object_ref (self) : NULL;
#line 91 "Debug.c"
}


static void
_debug_info_handler_glog_func (const gchar* log_domain,
                               GLogLevelFlags log_levels,
                               const gchar* message,
                               gpointer self)
{
#line 82 "/home/jens/Source/shotwell/src/Debug.vala"
	debug_info_handler (log_domain, log_levels, message);
#line 103 "Debug.c"
}


static void
_debug_debug_handler_glog_func (const gchar* log_domain,
                                GLogLevelFlags log_levels,
                                const gchar* message,
                                gpointer self)
{
#line 83 "/home/jens/Source/shotwell/src/Debug.vala"
	debug_debug_handler (log_domain, log_levels, message);
#line 115 "Debug.c"
}


static void
_debug_message_handler_glog_func (const gchar* log_domain,
                                  GLogLevelFlags log_levels,
                                  const gchar* message,
                                  gpointer self)
{
#line 84 "/home/jens/Source/shotwell/src/Debug.vala"
	debug_message_handler (log_domain, log_levels, message);
#line 127 "Debug.c"
}


static void
_debug_warning_handler_glog_func (const gchar* log_domain,
                                  GLogLevelFlags log_levels,
                                  const gchar* message,
                                  gpointer self)
{
#line 85 "/home/jens/Source/shotwell/src/Debug.vala"
	debug_warning_handler (log_domain, log_levels, message);
#line 139 "Debug.c"
}


static void
_debug_critical_handler_glog_func (const gchar* log_domain,
                                   GLogLevelFlags log_levels,
                                   const gchar* message,
                                   gpointer self)
{
#line 86 "/home/jens/Source/shotwell/src/Debug.vala"
	debug_critical_handler (log_domain, log_levels, message);
#line 151 "Debug.c"
}


void
debug_init (const gchar* app_version_prefix)
{
	gchar* _tmp0_;
	FILE* _tmp1_;
	FILE* _tmp2_;
	gchar* log_file_error_msg = NULL;
	GFile* _tmp3_ = NULL;
	const gchar* _tmp4_;
	GFile* log_file = NULL;
	GFile* _tmp6_;
	GFile* _tmp7_;
	const gchar* _tmp31_;
	gboolean _tmp52_ = FALSE;
	GLogLevelFlags _tmp53_;
	const gchar* _tmp55_;
	GError * _inner_error_ = NULL;
#line 27 "/home/jens/Source/shotwell/src/Debug.vala"
	g_return_if_fail (app_version_prefix != NULL);
#line 28 "/home/jens/Source/shotwell/src/Debug.vala"
	_tmp0_ = g_strdup (app_version_prefix);
#line 28 "/home/jens/Source/shotwell/src/Debug.vala"
	_g_free0 (debug_log_app_version_prefix);
#line 28 "/home/jens/Source/shotwell/src/Debug.vala"
	debug_log_app_version_prefix = _tmp0_;
#line 31 "/home/jens/Source/shotwell/src/Debug.vala"
	_tmp1_ = stdout;
#line 31 "/home/jens/Source/shotwell/src/Debug.vala"
	debug_log_out = _tmp1_;
#line 32 "/home/jens/Source/shotwell/src/Debug.vala"
	_tmp2_ = stderr;
#line 32 "/home/jens/Source/shotwell/src/Debug.vala"
	debug_log_err = _tmp2_;
#line 34 "/home/jens/Source/shotwell/src/Debug.vala"
	log_file_error_msg = NULL;
#line 37 "/home/jens/Source/shotwell/src/Debug.vala"
	_tmp4_ = debug_log_app_version_prefix;
#line 37 "/home/jens/Source/shotwell/src/Debug.vala"
	if (g_strcmp0 (_tmp4_, DEBUG_LIBRARY_PREFIX) == 0) {
#line 194 "Debug.c"
		GFile* _tmp5_;
#line 37 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp5_ = app_dirs_get_log_file ();
#line 37 "/home/jens/Source/shotwell/src/Debug.vala"
		_g_object_unref0 (_tmp3_);
#line 37 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp3_ = _tmp5_;
#line 202 "Debug.c"
	} else {
#line 37 "/home/jens/Source/shotwell/src/Debug.vala"
		_g_object_unref0 (_tmp3_);
#line 37 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp3_ = NULL;
#line 208 "Debug.c"
	}
#line 37 "/home/jens/Source/shotwell/src/Debug.vala"
	_tmp6_ = _g_object_ref0 (_tmp3_);
#line 37 "/home/jens/Source/shotwell/src/Debug.vala"
	log_file = _tmp6_;
#line 38 "/home/jens/Source/shotwell/src/Debug.vala"
	_tmp7_ = log_file;
#line 38 "/home/jens/Source/shotwell/src/Debug.vala"
	if (_tmp7_ != NULL) {
#line 218 "Debug.c"
		GFile* log_dir = NULL;
		GFile* _tmp8_;
		GFile* _tmp9_;
		GFile* _tmp20_;
		gchar* _tmp21_;
		gchar* _tmp22_;
		FILE* _tmp23_;
		FILE* _tmp24_;
#line 39 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp8_ = log_file;
#line 39 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp9_ = g_file_get_parent (_tmp8_);
#line 39 "/home/jens/Source/shotwell/src/Debug.vala"
		log_dir = _tmp9_;
#line 233 "Debug.c"
		{
			GFile* _tmp10_;
#line 41 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp10_ = log_dir;
#line 41 "/home/jens/Source/shotwell/src/Debug.vala"
			if (g_file_query_exists (_tmp10_, NULL) == FALSE) {
#line 240 "Debug.c"
				gboolean _tmp11_ = FALSE;
				GFile* _tmp12_;
#line 42 "/home/jens/Source/shotwell/src/Debug.vala"
				_tmp12_ = log_dir;
#line 42 "/home/jens/Source/shotwell/src/Debug.vala"
				_tmp11_ = g_file_make_directory_with_parents (_tmp12_, NULL, &_inner_error_);
#line 42 "/home/jens/Source/shotwell/src/Debug.vala"
				if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 249 "Debug.c"
					goto __catch441_g_error;
				}
#line 42 "/home/jens/Source/shotwell/src/Debug.vala"
				if (!_tmp11_) {
#line 254 "Debug.c"
					GFile* _tmp13_;
					gchar* _tmp14_;
					gchar* _tmp15_;
					gchar* _tmp16_;
#line 43 "/home/jens/Source/shotwell/src/Debug.vala"
					_tmp13_ = log_dir;
#line 43 "/home/jens/Source/shotwell/src/Debug.vala"
					_tmp14_ = g_file_get_path (_tmp13_);
#line 43 "/home/jens/Source/shotwell/src/Debug.vala"
					_tmp15_ = _tmp14_;
#line 43 "/home/jens/Source/shotwell/src/Debug.vala"
					_tmp16_ = g_strdup_printf ("Unable to create data directory %s", _tmp15_);
#line 43 "/home/jens/Source/shotwell/src/Debug.vala"
					_g_free0 (log_file_error_msg);
#line 43 "/home/jens/Source/shotwell/src/Debug.vala"
					log_file_error_msg = _tmp16_;
#line 43 "/home/jens/Source/shotwell/src/Debug.vala"
					_g_free0 (_tmp15_);
#line 273 "Debug.c"
				}
			}
		}
		goto __finally441;
		__catch441_g_error:
		{
			GError* err = NULL;
			GError* _tmp17_;
			const gchar* _tmp18_;
			gchar* _tmp19_;
#line 40 "/home/jens/Source/shotwell/src/Debug.vala"
			err = _inner_error_;
#line 40 "/home/jens/Source/shotwell/src/Debug.vala"
			_inner_error_ = NULL;
#line 47 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp17_ = err;
#line 47 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp18_ = _tmp17_->message;
#line 47 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp19_ = g_strdup (_tmp18_);
#line 47 "/home/jens/Source/shotwell/src/Debug.vala"
			_g_free0 (log_file_error_msg);
#line 47 "/home/jens/Source/shotwell/src/Debug.vala"
			log_file_error_msg = _tmp19_;
#line 40 "/home/jens/Source/shotwell/src/Debug.vala"
			_g_error_free0 (err);
#line 300 "Debug.c"
		}
		__finally441:
#line 40 "/home/jens/Source/shotwell/src/Debug.vala"
		if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 40 "/home/jens/Source/shotwell/src/Debug.vala"
			_g_object_unref0 (log_dir);
#line 40 "/home/jens/Source/shotwell/src/Debug.vala"
			_g_object_unref0 (log_file);
#line 40 "/home/jens/Source/shotwell/src/Debug.vala"
			_g_object_unref0 (_tmp3_);
#line 40 "/home/jens/Source/shotwell/src/Debug.vala"
			_g_free0 (log_file_error_msg);
#line 40 "/home/jens/Source/shotwell/src/Debug.vala"
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
#line 40 "/home/jens/Source/shotwell/src/Debug.vala"
			g_clear_error (&_inner_error_);
#line 40 "/home/jens/Source/shotwell/src/Debug.vala"
			return;
#line 319 "Debug.c"
		}
#line 53 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp20_ = log_file;
#line 53 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp21_ = g_file_get_path (_tmp20_);
#line 53 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp22_ = _tmp21_;
#line 53 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp23_ = g_fopen (_tmp22_, "w");
#line 53 "/home/jens/Source/shotwell/src/Debug.vala"
		_fclose0 (debug_log_file_stream);
#line 53 "/home/jens/Source/shotwell/src/Debug.vala"
		debug_log_file_stream = _tmp23_;
#line 53 "/home/jens/Source/shotwell/src/Debug.vala"
		_g_free0 (_tmp22_);
#line 54 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp24_ = debug_log_file_stream;
#line 54 "/home/jens/Source/shotwell/src/Debug.vala"
		if (_tmp24_ != NULL) {
#line 339 "Debug.c"
			FILE* _tmp25_;
			FILE* _tmp26_;
#line 55 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp25_ = debug_log_file_stream;
#line 55 "/home/jens/Source/shotwell/src/Debug.vala"
			debug_log_out = _tmp25_;
#line 56 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp26_ = debug_log_file_stream;
#line 56 "/home/jens/Source/shotwell/src/Debug.vala"
			debug_log_err = _tmp26_;
#line 350 "Debug.c"
		} else {
			GFile* _tmp27_;
			gchar* _tmp28_;
			gchar* _tmp29_;
			gchar* _tmp30_;
#line 58 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp27_ = log_file;
#line 58 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp28_ = g_file_get_path (_tmp27_);
#line 58 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp29_ = _tmp28_;
#line 58 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp30_ = g_strdup_printf ("Unable to open or create log file %s", _tmp29_);
#line 58 "/home/jens/Source/shotwell/src/Debug.vala"
			_g_free0 (log_file_error_msg);
#line 58 "/home/jens/Source/shotwell/src/Debug.vala"
			log_file_error_msg = _tmp30_;
#line 58 "/home/jens/Source/shotwell/src/Debug.vala"
			_g_free0 (_tmp29_);
#line 370 "Debug.c"
		}
#line 38 "/home/jens/Source/shotwell/src/Debug.vala"
		_g_object_unref0 (log_dir);
#line 374 "Debug.c"
	}
#line 62 "/home/jens/Source/shotwell/src/Debug.vala"
	_tmp31_ = g_getenv ("SHOTWELL_LOG");
#line 62 "/home/jens/Source/shotwell/src/Debug.vala"
	if (_tmp31_ != NULL) {
#line 63 "/home/jens/Source/shotwell/src/Debug.vala"
		debug_log_mask = G_LOG_LEVEL_MASK;
#line 382 "Debug.c"
	} else {
		GLogLevelFlags _tmp32_ = 0;
		const gchar* _tmp33_;
		GLogLevelFlags _tmp36_ = 0;
		const gchar* _tmp37_;
		GLogLevelFlags _tmp40_ = 0;
		const gchar* _tmp41_;
		GLogLevelFlags _tmp44_ = 0;
		const gchar* _tmp45_;
		GLogLevelFlags _tmp48_ = 0;
		const gchar* _tmp49_;
#line 65 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp33_ = g_getenv ("SHOTWELL_INFO");
#line 65 "/home/jens/Source/shotwell/src/Debug.vala"
		if (_tmp33_ != NULL) {
#line 398 "Debug.c"
			GLogLevelFlags _tmp34_;
#line 66 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp34_ = debug_log_mask;
#line 66 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp32_ = _tmp34_ | G_LOG_LEVEL_INFO;
#line 404 "Debug.c"
		} else {
			GLogLevelFlags _tmp35_;
#line 67 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp35_ = debug_log_mask;
#line 67 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp32_ = _tmp35_;
#line 411 "Debug.c"
		}
#line 65 "/home/jens/Source/shotwell/src/Debug.vala"
		debug_log_mask = _tmp32_;
#line 68 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp37_ = g_getenv ("SHOTWELL_DEBUG");
#line 68 "/home/jens/Source/shotwell/src/Debug.vala"
		if (_tmp37_ != NULL) {
#line 419 "Debug.c"
			GLogLevelFlags _tmp38_;
#line 69 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp38_ = debug_log_mask;
#line 69 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp36_ = _tmp38_ | G_LOG_LEVEL_DEBUG;
#line 425 "Debug.c"
		} else {
			GLogLevelFlags _tmp39_;
#line 70 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp39_ = debug_log_mask;
#line 70 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp36_ = _tmp39_;
#line 432 "Debug.c"
		}
#line 68 "/home/jens/Source/shotwell/src/Debug.vala"
		debug_log_mask = _tmp36_;
#line 71 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp41_ = g_getenv ("SHOTWELL_MESSAGE");
#line 71 "/home/jens/Source/shotwell/src/Debug.vala"
		if (_tmp41_ != NULL) {
#line 440 "Debug.c"
			GLogLevelFlags _tmp42_;
#line 72 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp42_ = debug_log_mask;
#line 72 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp40_ = _tmp42_ | G_LOG_LEVEL_MESSAGE;
#line 446 "Debug.c"
		} else {
			GLogLevelFlags _tmp43_;
#line 73 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp43_ = debug_log_mask;
#line 73 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp40_ = _tmp43_;
#line 453 "Debug.c"
		}
#line 71 "/home/jens/Source/shotwell/src/Debug.vala"
		debug_log_mask = _tmp40_;
#line 74 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp45_ = g_getenv ("SHOTWELL_WARNING");
#line 74 "/home/jens/Source/shotwell/src/Debug.vala"
		if (_tmp45_ != NULL) {
#line 461 "Debug.c"
			GLogLevelFlags _tmp46_;
#line 75 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp46_ = debug_log_mask;
#line 75 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp44_ = _tmp46_ | G_LOG_LEVEL_WARNING;
#line 467 "Debug.c"
		} else {
			GLogLevelFlags _tmp47_;
#line 76 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp47_ = debug_log_mask;
#line 76 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp44_ = _tmp47_;
#line 474 "Debug.c"
		}
#line 74 "/home/jens/Source/shotwell/src/Debug.vala"
		debug_log_mask = _tmp44_;
#line 77 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp49_ = g_getenv ("SHOTWELL_CRITICAL");
#line 77 "/home/jens/Source/shotwell/src/Debug.vala"
		if (_tmp49_ != NULL) {
#line 482 "Debug.c"
			GLogLevelFlags _tmp50_;
#line 78 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp50_ = debug_log_mask;
#line 78 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp48_ = _tmp50_ | G_LOG_LEVEL_CRITICAL;
#line 488 "Debug.c"
		} else {
			GLogLevelFlags _tmp51_;
#line 79 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp51_ = debug_log_mask;
#line 79 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp48_ = _tmp51_;
#line 495 "Debug.c"
		}
#line 77 "/home/jens/Source/shotwell/src/Debug.vala"
		debug_log_mask = _tmp48_;
#line 499 "Debug.c"
	}
#line 82 "/home/jens/Source/shotwell/src/Debug.vala"
	g_log_set_handler (NULL, G_LOG_LEVEL_INFO, _debug_info_handler_glog_func, NULL);
#line 83 "/home/jens/Source/shotwell/src/Debug.vala"
	g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, _debug_debug_handler_glog_func, NULL);
#line 84 "/home/jens/Source/shotwell/src/Debug.vala"
	g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE, _debug_message_handler_glog_func, NULL);
#line 85 "/home/jens/Source/shotwell/src/Debug.vala"
	g_log_set_handler (NULL, G_LOG_LEVEL_WARNING, _debug_warning_handler_glog_func, NULL);
#line 86 "/home/jens/Source/shotwell/src/Debug.vala"
	g_log_set_handler (NULL, G_LOG_LEVEL_CRITICAL, _debug_critical_handler_glog_func, NULL);
#line 88 "/home/jens/Source/shotwell/src/Debug.vala"
	_tmp53_ = debug_log_mask;
#line 88 "/home/jens/Source/shotwell/src/Debug.vala"
	if (_tmp53_ == 0) {
#line 515 "Debug.c"
		GFile* _tmp54_;
#line 88 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp54_ = log_file;
#line 88 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp52_ = _tmp54_ != NULL;
#line 521 "Debug.c"
	} else {
#line 88 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp52_ = FALSE;
#line 525 "Debug.c"
	}
#line 88 "/home/jens/Source/shotwell/src/Debug.vala"
	if (_tmp52_) {
#line 91 "/home/jens/Source/shotwell/src/Debug.vala"
		debug_log_mask = DEBUG_DEFAULT_LOG_MASK;
#line 531 "Debug.c"
	}
#line 94 "/home/jens/Source/shotwell/src/Debug.vala"
	_tmp55_ = log_file_error_msg;
#line 94 "/home/jens/Source/shotwell/src/Debug.vala"
	if (_tmp55_ != NULL) {
#line 537 "Debug.c"
		const gchar* _tmp56_;
#line 95 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp56_ = log_file_error_msg;
#line 95 "/home/jens/Source/shotwell/src/Debug.vala"
		g_warning ("Debug.vala:95: %s", _tmp56_);
#line 543 "Debug.c"
	}
#line 27 "/home/jens/Source/shotwell/src/Debug.vala"
	_g_object_unref0 (log_file);
#line 27 "/home/jens/Source/shotwell/src/Debug.vala"
	_g_object_unref0 (_tmp3_);
#line 27 "/home/jens/Source/shotwell/src/Debug.vala"
	_g_free0 (log_file_error_msg);
#line 551 "Debug.c"
}


void
debug_terminate (void)
{
}


gboolean
debug_is_enabled (GLogLevelFlags flag)
{
	gboolean result = FALSE;
	GLogLevelFlags _tmp0_;
#line 103 "/home/jens/Source/shotwell/src/Debug.vala"
	_tmp0_ = debug_log_mask;
#line 103 "/home/jens/Source/shotwell/src/Debug.vala"
	result = (_tmp0_ & flag) > 0;
#line 103 "/home/jens/Source/shotwell/src/Debug.vala"
	return result;
#line 572 "Debug.c"
}


static void
g_time_local (time_t time,
              struct tm* result)
{
	struct tm _result_ = {0};
	struct tm _tmp0_ = {0};
#line 2866 "/usr/share/vala-0.40/vapi/glib-2.0.vapi"
	localtime_r (&time, &_tmp0_);
#line 2866 "/usr/share/vala-0.40/vapi/glib-2.0.vapi"
	_result_ = _tmp0_;
#line 2867 "/usr/share/vala-0.40/vapi/glib-2.0.vapi"
	*result = _result_;
#line 2867 "/usr/share/vala-0.40/vapi/glib-2.0.vapi"
	return;
#line 590 "Debug.c"
}


static gchar*
g_time_to_string (struct tm *self)
{
	gchar* result = NULL;
	gint _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gchar* _tmp6_;
#line 2871 "/usr/share/vala-0.40/vapi/glib-2.0.vapi"
	_tmp0_ = (*self).tm_year;
#line 2871 "/usr/share/vala-0.40/vapi/glib-2.0.vapi"
	_tmp1_ = (*self).tm_mon;
#line 2871 "/usr/share/vala-0.40/vapi/glib-2.0.vapi"
	_tmp2_ = (*self).tm_mday;
#line 2871 "/usr/share/vala-0.40/vapi/glib-2.0.vapi"
	_tmp3_ = (*self).tm_hour;
#line 2871 "/usr/share/vala-0.40/vapi/glib-2.0.vapi"
	_tmp4_ = (*self).tm_min;
#line 2871 "/usr/share/vala-0.40/vapi/glib-2.0.vapi"
	_tmp5_ = (*self).tm_sec;
#line 2871 "/usr/share/vala-0.40/vapi/glib-2.0.vapi"
	_tmp6_ = g_strdup_printf ("%04d-%02d-%02d %02d:%02d:%02d", _tmp0_ + 1900, _tmp1_ + 1, _tmp2_, _tmp3_, _tmp4_, _tmp5_);
#line 2871 "/usr/share/vala-0.40/vapi/glib-2.0.vapi"
	result = _tmp6_;
#line 2871 "/usr/share/vala-0.40/vapi/glib-2.0.vapi"
	return result;
#line 623 "Debug.c"
}


void
debug_log (FILE* stream,
           const gchar* prefix,
           const gchar* message)
{
	time_t now = 0;
	time_t _tmp0_;
	const gchar* _tmp1_;
	struct tm _tmp2_ = {0};
	gchar* _tmp3_;
	gchar* _tmp4_;
#line 106 "/home/jens/Source/shotwell/src/Debug.vala"
	g_return_if_fail (stream != NULL);
#line 106 "/home/jens/Source/shotwell/src/Debug.vala"
	g_return_if_fail (prefix != NULL);
#line 106 "/home/jens/Source/shotwell/src/Debug.vala"
	g_return_if_fail (message != NULL);
#line 107 "/home/jens/Source/shotwell/src/Debug.vala"
	_tmp0_ = time (NULL);
#line 107 "/home/jens/Source/shotwell/src/Debug.vala"
	now = _tmp0_;
#line 108 "/home/jens/Source/shotwell/src/Debug.vala"
	_tmp1_ = debug_log_app_version_prefix;
#line 108 "/home/jens/Source/shotwell/src/Debug.vala"
	g_time_local (now, &_tmp2_);
#line 108 "/home/jens/Source/shotwell/src/Debug.vala"
	_tmp3_ = g_time_to_string (&_tmp2_);
#line 108 "/home/jens/Source/shotwell/src/Debug.vala"
	_tmp4_ = _tmp3_;
#line 108 "/home/jens/Source/shotwell/src/Debug.vala"
	fprintf (stream, "%s %d %s [%s] %s\n", _tmp1_, (gint) getpid (), _tmp4_, prefix, message);
#line 108 "/home/jens/Source/shotwell/src/Debug.vala"
	_g_free0 (_tmp4_);
#line 115 "/home/jens/Source/shotwell/src/Debug.vala"
	fflush (stream);
#line 662 "Debug.c"
}


void
debug_info_handler (const gchar* domain,
                    GLogLevelFlags flags,
                    const gchar* message)
{
#line 118 "/home/jens/Source/shotwell/src/Debug.vala"
	g_return_if_fail (message != NULL);
#line 119 "/home/jens/Source/shotwell/src/Debug.vala"
	if (debug_is_enabled (G_LOG_LEVEL_INFO)) {
#line 675 "Debug.c"
		FILE* _tmp0_;
#line 120 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp0_ = debug_log_out;
#line 120 "/home/jens/Source/shotwell/src/Debug.vala"
		debug_log (_tmp0_, "INF", message);
#line 681 "Debug.c"
	}
}


void
debug_debug_handler (const gchar* domain,
                     GLogLevelFlags flags,
                     const gchar* message)
{
#line 123 "/home/jens/Source/shotwell/src/Debug.vala"
	g_return_if_fail (message != NULL);
#line 124 "/home/jens/Source/shotwell/src/Debug.vala"
	if (debug_is_enabled (G_LOG_LEVEL_DEBUG)) {
#line 695 "Debug.c"
		FILE* _tmp0_;
#line 125 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp0_ = debug_log_out;
#line 125 "/home/jens/Source/shotwell/src/Debug.vala"
		debug_log (_tmp0_, "DBG", message);
#line 701 "Debug.c"
	}
}


void
debug_message_handler (const gchar* domain,
                       GLogLevelFlags flags,
                       const gchar* message)
{
#line 128 "/home/jens/Source/shotwell/src/Debug.vala"
	g_return_if_fail (message != NULL);
#line 129 "/home/jens/Source/shotwell/src/Debug.vala"
	if (debug_is_enabled (G_LOG_LEVEL_MESSAGE)) {
#line 715 "Debug.c"
		FILE* _tmp0_;
#line 130 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp0_ = debug_log_err;
#line 130 "/home/jens/Source/shotwell/src/Debug.vala"
		debug_log (_tmp0_, "MSG", message);
#line 721 "Debug.c"
	}
}


void
debug_warning_handler (const gchar* domain,
                       GLogLevelFlags flags,
                       const gchar* message)
{
#line 133 "/home/jens/Source/shotwell/src/Debug.vala"
	g_return_if_fail (message != NULL);
#line 134 "/home/jens/Source/shotwell/src/Debug.vala"
	if (debug_is_enabled (G_LOG_LEVEL_WARNING)) {
#line 735 "Debug.c"
		FILE* _tmp0_;
#line 135 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp0_ = debug_log_err;
#line 135 "/home/jens/Source/shotwell/src/Debug.vala"
		debug_log (_tmp0_, "WRN", message);
#line 741 "Debug.c"
	}
}


void
debug_critical_handler (const gchar* domain,
                        GLogLevelFlags flags,
                        const gchar* message)
{
#line 138 "/home/jens/Source/shotwell/src/Debug.vala"
	g_return_if_fail (message != NULL);
#line 139 "/home/jens/Source/shotwell/src/Debug.vala"
	if (debug_is_enabled (G_LOG_LEVEL_CRITICAL)) {
#line 755 "Debug.c"
		FILE* _tmp0_;
		FILE* _tmp1_;
#line 140 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp0_ = debug_log_err;
#line 140 "/home/jens/Source/shotwell/src/Debug.vala"
		debug_log (_tmp0_, "CRT", message);
#line 141 "/home/jens/Source/shotwell/src/Debug.vala"
		_tmp1_ = debug_log_file_stream;
#line 141 "/home/jens/Source/shotwell/src/Debug.vala"
		if (_tmp1_ != NULL) {
#line 766 "Debug.c"
			FILE* _tmp2_;
#line 142 "/home/jens/Source/shotwell/src/Debug.vala"
			_tmp2_ = stderr;
#line 142 "/home/jens/Source/shotwell/src/Debug.vala"
			debug_log (_tmp2_, "CRT", message);
#line 772 "Debug.c"
		}
	}
}



