Commit b8ac437
log export to file
Changed files (7)
modifiedconfiguremodifiedlibbirdfont/BirdFont.valamodifiedlibbirdfont/BirdFontFile.valamodifiedlibbirdfont/Font.valamodifiedlibbirdfont/MoveTool.valamodifiedlibbirdfont/OpenFontFormat/OpenFontFormatWriter.valamodifiedlibbirdfont/ResizeTool.vala
Diff
@@ -54,7 +54,7 @@ def configure (): libs = [ 'cairo', 'gdk-pixbuf-2.0', - 'gee-1.0',+ 'gee-0.8', 'gio-2.0', 'glib-2.0', 'gtk+-2.0',@@ -43,6 +43,8 @@ public static int run_export (string[] arg) { return -1; } + init_logfile ();+ for (int i = 1; i < arg.length; i++) { if (arg[i] == "-f" || arg[i] == "--fatal-warnings") {@@ -183,6 +185,9 @@ public class BirdFont { public static string exec_path = ""; public static string bundle_path = ""; + public static bool logging = false;+ public static DataOutputStream? logstream = null;+ public static Font current_font; public static Glyph current_glyph; @@ -363,4 +368,51 @@ public class BirdFont { } } +void init_logfile () {+ DateTime t;+ File settings;+ string s;+ + LogLevelFlags levels = LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL | LogLevelFlags.LEVEL_WARNING | LogLevelFlags.LEVEL_DEBUG;+ Log.set_handler (null, levels, log_warning); + + try {+ t = new DateTime.now_local ();+ settings = BirdFont.get_settings_directory ();+ s = t.to_string ();+ File log = settings.get_child (@"birdfont_$s.log"); + BirdFont.logstream = new DataOutputStream (log.create (FileCreateFlags.REPLACE_DESTINATION));+ } catch (GLib.Error e) {+ warning (e.message);+ }+ + BirdFont.logging = true;+}++internal static void log_warning (string? log_domain, LogLevelFlags log_levels, string message) {+ if (log_domain != null) {+ printd ((!) log_domain);+ }+ + printd ("\n");+ printd (message);+ printd ("\n");+ printd ("\n");+}++/** Write debug output to logfile. */+void printd (string s) {+ if (unlikely (BirdFont.logging)) {+ try {+ if (BirdFont.logstream != null) {+ ((!)BirdFont.logstream).put_string (s);+ } else {+ warning ("No logstream.");+ }+ } catch (GLib.Error e) {+ warning (e.message);+ }+ }+}+ }@@ -36,7 +36,9 @@ class BirdFontFile { Xml.Node* root; Parser.init ();-+ + printd (@"Loading $path\n");+ font.font_file = path; // this will be updated if we are loading a backup file doc = Parser.parse_file (path);@@ -464,7 +466,10 @@ class BirdFontFile { Xml.Node* node = root; for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {-+ + printd (iter->name); // FIXME: delete+ printd ("\n");+ // this is a backup file set path to the original if (iter->name == "backup") { font.font_file = iter->children->content;@@ -498,6 +503,15 @@ class BirdFontFile { if (iter->name == "postscript_name" && iter->children != null) { font.postscript_name = iter->children->content;+ + printd ("PostScript name:"); // FIXME: delete when debugging is done+ printd (iter->children->content);+ printd ("\n");+ }+ + // FIXME: delete when debugging is done+ if (iter->name == "postscript_name" && iter->children == null) {+ printd ("Found PostScipt name but content for this node is null in libxml.\n"); } if (iter->name == "name" && iter->children != null) {@@ -333,6 +333,8 @@ public class Font : GLib.Object { } glyph_cache.insert (glyph_collection.get_unicode (), glyph_collection);+ + printd (@"Adding $(glyph_collection.get_current ().get_name ())\n"); } public string get_name_for_character (unichar c) {@@ -64,8 +64,6 @@ class MoveTool : Tool { } public static void draw_actions (Context cr) {- Glyph g = MainWindow.get_current_glyph ();- if (group_selection) { draw_selection_box (cr); }@@ -75,8 +75,4 @@ class OpenFontFormatWriter : Object { } } -void printd (string s) {- //print (s);-}- }@@ -207,13 +207,6 @@ class ResizeTool : Tool { cr.restore (); }- - static void update_selection_boundries () {- MoveTool.update_boundries_for_selection ();- MoveTool.get_selection_box_boundries (out selection_box_center_x,- out selection_box_center_y, out selection_box_width,- out selection_box_height); - } double get_resize_ratio (double x, double y) { double ratio;