Mercurial > repos > IBBoard
annotate Logging/TextFileLogger.cs @ 100:fa8378a30ed2
* Add some Stream handling utilities
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 06 Mar 2011 14:51:05 +0000 |
parents | cc7fae81afec |
children |
rev | line source |
---|---|
16 | 1 // This file (TextFileLogger.cs) is a part of the IBBoard library and is copyright 2009 IBBoard. |
2 // | |
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. | |
4 | |
37 | 5 using System; |
0
961030992bd2
Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 using System.IO; |
37 | 7 using IBBoard; |
8 | |
9 namespace IBBoard.Logging | |
10 { | |
11 /// <summary> | |
12 /// Summary description for FileLogger. | |
13 /// </summary> | |
14 public class TextFileLogger : FileLogger | |
0
961030992bd2
Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 { |
961030992bd2
Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 public TextFileLogger() : base() |
961030992bd2
Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 { |
961030992bd2
Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 } |
961030992bd2
Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 |
37 | 20 public TextFileLogger(string path) : base(path) |
21 { | |
22 } | |
23 | |
24 protected override void LogMessage(LogItem item) | |
25 { | |
26 string stack = item.StackTrace; | |
27 string message = item.Message + Environment.NewLine + (stack!= "" ? stack + Environment.NewLine : ""); | |
28 LogMessageString(message); | |
0
961030992bd2
Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 } |
961030992bd2
Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 |
961030992bd2
Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 protected override void LogMessageString (string str) |
961030992bd2
Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 { |
961030992bd2
Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 str.TrimEnd(); |
961030992bd2
Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 str+= Environment.NewLine + Environment.NewLine; |
37 | 35 stream.Write(encoding.GetBytes(str), 0, encoding.GetByteCount(str)); |
0
961030992bd2
Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 stream.Flush(); |
961030992bd2
Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 } |
37 | 38 |
39 } | |
40 } |