Browse Source

WIP: Log warnings to file

Neal Wilson 10 years ago
parent
commit
288d3f3594
2 changed files with 2517 additions and 2442 deletions
  1. 2489
    2442
      src/typica.cpp
  2. 28
    0
      src/typica.w

+ 2489
- 2442
src/typica.cpp
File diff suppressed because it is too large
View File


+ 28
- 0
src/typica.w View File

525
 @<Header files to include@>@/
525
 @<Header files to include@>@/
526
 @<Class declarations@>@/
526
 @<Class declarations@>@/
527
 @<Function prototypes for scripting@>@/
527
 @<Function prototypes for scripting@>@/
528
+@<Logging function prototype@>@/
528
 @<Class implementations@>@/
529
 @<Class implementations@>@/
529
 @<Functions for scripting@>@/
530
 @<Functions for scripting@>@/
531
+@<Logging function implementation@>@/
530
 @<The main program@>
532
 @<The main program@>
531
 #include "moc_typica.cpp"
533
 #include "moc_typica.cpp"
532
 
534
 
12717
 @<The main program@>=
12719
 @<The main program@>=
12718
 int main(int argc, char **argv)@/
12720
 int main(int argc, char **argv)@/
12719
 {@/
12721
 {@/
12722
+	@<Set up logging@>@;
12720
 	int *c = &argc;
12723
 	int *c = &argc;
12721
 	Application app(*c, argv);
12724
 	Application app(*c, argv);
12722
 	@<Set up icons@>@;
12725
 	@<Set up icons@>@;
12736
 	return retval;@/
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
 @ \pn{} 1.4 introduces the ability to use icons in certain interface elements.
12767
 @ \pn{} 1.4 introduces the ability to use icons in certain interface elements.
12740
 Some commonly desired public domain graphics are provided by the Tango Desktop
12768
 Some commonly desired public domain graphics are provided by the Tango Desktop
12741
 Project. We also set an application level default window icon.
12769
 Project. We also set an application level default window icon.

Loading…
Cancel
Save