浏览代码

WIP: Log warnings to file

Neal Wilson 10 年前
父节点
当前提交
288d3f3594
共有 2 个文件被更改,包括 2517 次插入2442 次删除
  1. 2489
    2442
      src/typica.cpp
  2. 28
    0
      src/typica.w

+ 2489
- 2442
src/typica.cpp
文件差异内容过多而无法显示
查看文件


+ 28
- 0
src/typica.w 查看文件

@@ -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.

正在加载...
取消
保存