Blob Blame History Raw
<?xml version="1.0"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "">
<refentry id="gdata-running">
		<refentrytitle role="top_of_page" id="gdata-overview.top_of_page">Running GData Applications</refentrytitle>
		<refmiscinfo>GDATA Library</refmiscinfo>
		<refname>Running GData Applications</refname>
		<refpurpose>running and debugging GData applications</refpurpose>

		<title>Running and Debugging GData Applications</title>

			<title>Environment variables</title>
			<para>libgdata makes use of a few environment variables which affect how it runs, mainly with respect to debugging.</para>

			<formalpara id="LIBGDATA_DEBUG">
				<para>If this environment variable is set to one of the following values, libgdata will give debug output
					(at various levels). If it's unset, no debug output will be produced.
							<listitem><para>Output no debug messages or network logs.</para></listitem>
							<listitem><para>Output debug messages, but not network logs.</para></listitem>
							<listitem><para>Output debug messages and network traffic headers.</para></listitem>
							<listitem><para>Output debug messages and full network traffic logs.</para></listitem>
				<para>So, to debug a program which uses libgdata, run it from a terminal with the following command:</para>
				<screen><prompt>$</prompt><userinput>LIBGDATA_DEBUG=3 ./my-program-name &amp;> libgdata.log</userinput></screen>

			<title>Debugging Advice</title>
			<para>The easiest way to debug problems with libgdata is to use the
			      <link linkend="LIBGDATA_DEBUG"><envar>LIBGDATA_DEBUG</envar></link> environment variable to observe all the network
			      traffic being transmitted and received by libgdata. Typically, any problems will occur in the final network
			      request/response, which is the last one in the log output.</para>
			<para>If debugging using the environment variables and log output is not possible, it is sometimes possible to diagnose problems
			      by examining the error responses sent by the Google servers to libgdata. These are exposed as the error messages returned
			      by libgdata methods; so when handling errors from libgdata method calls, it is a good idea to output the message from
			      the <link linkend="GError"><type>GError</type></link> to a debug log, or even as a warning in the user's
			      <filename>.xsession-errors</filename> file.</para>
				<title>Error Handling when Uploading a Document</title>
				GDataUploadStream *upload_stream;
				GError *error = NULL; /<!-- -->* make sure to initialise the GError to NULL *<!-- -->/

				/<!-- -->* Other code goes here. *<!-- -->/

				upload_stream = gdata_documents_service_upload_document (service, document, slug, content_type, destination_folder, NULL,

				/<!-- -->* Handle any errors. *<!-- -->/
				if (error != NULL) {
					/<!-- -->* Note that the error message is outputted to the terminal/logs.
					 * It will contain important debugging information from the Google servers. *<!-- -->/
					g_error ("Error getting upload stream: %s", error->message);
					g_error_free (error);