Parcourir la source

WIP: Log warnings to file

Neal Wilson il y a 9 ans
Parent
révision
288d3f3594
2 fichiers modifiés avec 2517 ajouts et 2442 suppressions
  1. 2489
    2442
      src/typica.cpp
  2. 28
    0
      src/typica.w

+ 2489
- 2442
src/typica.cpp
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


+ 28
- 0
src/typica.w Voir le fichier

@@ -525,8 +525,10 @@ generated file empty.
525 525
 @<Header files to include@>@/
526 526
 @<Class declarations@>@/
527 527
 @<Function prototypes for scripting@>@/
528
+@<Logging function prototype@>@/
528 529
 @<Class implementations@>@/
529 530
 @<Functions for scripting@>@/
531
+@<Logging function implementation@>@/
530 532
 @<The main program@>
531 533
 #include "moc_typica.cpp"
532 534
 
@@ -12717,6 +12719,7 @@ build.
12717 12719
 @<The main program@>=
12718 12720
 int main(int argc, char **argv)@/
12719 12721
 {@/
12722
+	@<Set up logging@>@;
12720 12723
 	int *c = &argc;
12721 12724
 	Application app(*c, argv);
12722 12725
 	@<Set up icons@>@;
@@ -12736,6 +12739,31 @@ int main(int argc, char **argv)@/
12736 12739
 	return retval;@/
12737 12740
 }
12738 12741
 
12742
+@ Proof of concept for the introduction of logging warnings to a file. This is
12743
+primarily for the benefit of people using Windows without an attached debugger.
12744
+Before this is merged to development it should allow the person using Typica
12745
+more control over if this should be enabled (by default it should not) and
12746
+where the output is sent.
12747
+
12748
+@<Set up logging@>=
12749
+qInstallMsgHandler(messageFileOutput);
12750
+
12751
+@ This requires that we have our messageFileOutput function.
12752
+
12753
+@<Logging function prototype@>=
12754
+void messageFileOutput(QtMsgType type, const char *msg);
12755
+
12756
+@ The current implementation is straightforward.
12757
+
12758
+@<Logging function implementation@>=
12759
+void messageFileOutput(QtMsgType type, const char *msg)
12760
+{
12761
+	QFile output("Typica-"+QDate::currentDate().toString("yyyy-MM-dd")+".log");
12762
+	output.open(QIODevice::WriteOnly | QIODevice::Append);
12763
+	QTextStream outstream(&output);
12764
+	outstream << msg << "\n";
12765
+}
12766
+
12739 12767
 @ \pn{} 1.4 introduces the ability to use icons in certain interface elements.
12740 12768
 Some commonly desired public domain graphics are provided by the Tango Desktop
12741 12769
 Project. We also set an application level default window icon.

Chargement…
Annuler
Enregistrer