summaryrefslogtreecommitdiff
path: root/src/simple-scan.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/simple-scan.vala')
-rw-r--r--src/simple-scan.vala75
1 files changed, 32 insertions, 43 deletions
diff --git a/src/simple-scan.vala b/src/simple-scan.vala
index 0cc2c8d..1176053 100644
--- a/src/simple-scan.vala
+++ b/src/simple-scan.vala
@@ -91,7 +91,7 @@ public class SimpleScan : Gtk.Application
udev_client = null;
scanner.free ();
}
-
+
private void update_scan_devices_cb (Scanner scanner, List<ScanDevice> devices)
{
var devices_copy = devices.copy ();
@@ -242,7 +242,7 @@ public class SimpleScan : Gtk.Application
return profile.filename;
#else
return null;
-#endif
+#endif
}
private void scanner_page_info_cb (Scanner scanner, ScanPageInfo info)
@@ -418,54 +418,43 @@ public class SimpleScan : Gtk.Application
private static void log_cb (string? log_domain, LogLevelFlags log_level, string message)
{
- /* Log everything to a file */
- if (log_file != null)
- {
- string prefix;
-
- switch (log_level & LogLevelFlags.LEVEL_MASK)
- {
- case LogLevelFlags.LEVEL_ERROR:
- prefix = "ERROR:";
- break;
- case LogLevelFlags.LEVEL_CRITICAL:
- prefix = "CRITICAL:";
- break;
- case LogLevelFlags.LEVEL_WARNING:
- prefix = "WARNING:";
- break;
- case LogLevelFlags.LEVEL_MESSAGE:
- prefix = "MESSAGE:";
- break;
- case LogLevelFlags.LEVEL_INFO:
- prefix = "INFO:";
- break;
- case LogLevelFlags.LEVEL_DEBUG:
- prefix = "DEBUG:";
- break;
- default:
- prefix = "LOG:";
- break;
- }
+ string prefix;
- log_file.printf ("[%+.2fs] %s %s\n", log_timer.elapsed (), prefix, message);
- }
-
- /* Only show debug if requested */
- if ((log_level & LogLevelFlags.LEVEL_DEBUG) != 0)
+ switch (log_level & LogLevelFlags.LEVEL_MASK)
{
- if (debug_enabled)
- Log.default_handler (log_domain, log_level, message);
+ case LogLevelFlags.LEVEL_ERROR:
+ prefix = "ERROR:";
+ break;
+ case LogLevelFlags.LEVEL_CRITICAL:
+ prefix = "CRITICAL:";
+ break;
+ case LogLevelFlags.LEVEL_WARNING:
+ prefix = "WARNING:";
+ break;
+ case LogLevelFlags.LEVEL_MESSAGE:
+ prefix = "MESSAGE:";
+ break;
+ case LogLevelFlags.LEVEL_INFO:
+ prefix = "INFO:";
+ break;
+ case LogLevelFlags.LEVEL_DEBUG:
+ prefix = "DEBUG:";
+ break;
+ default:
+ prefix = "LOG:";
+ break;
}
- else
- Log.default_handler (log_domain, log_level, message);
+
+ log_file.printf ("[%+.2fs] %s %s\n", log_timer.elapsed (), prefix, message);
+ if (debug_enabled)
+ stderr.printf ("[%+.2fs] %s %s\n", log_timer.elapsed (), prefix, message);
}
private void on_uevent (GUdev.Client client, string action, GUdev.Device device)
{
scanner.redetect ();
}
-
+
private static void fix_pdf (string filename) throws Error
{
uint8[] data;
@@ -522,7 +511,7 @@ public class SimpleScan : Gtk.Application
line_number++;
offset = end_offset;
}
-
+
if (FileUtils.rename (filename, filename + "~") >= 0)
FileUtils.rename (filename + ".fixed", filename);
}
@@ -569,7 +558,7 @@ public class SimpleScan : Gtk.Application
catch (Error e)
{
stderr.printf ("Error fixing PDF file: %s", e.message);
- return Posix.EXIT_FAILURE;
+ return Posix.EXIT_FAILURE;
}
return Posix.EXIT_SUCCESS;
}