Created
November 26, 2010 07:52
-
-
Save noqisofon/716392 to your computer and use it in GitHub Desktop.
ちょー簡単なろがークラス。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Text; | |
namespace halfmoon.util { | |
/// <summary> | |
/// | |
/// </summary> | |
public static class Logger { | |
/// <summary> | |
/// | |
/// </summary> | |
/// <param name="e"></param> | |
public static void log(Exception e) { | |
DateTime now = DateTime.Now; | |
StringBuilder message_builder = new StringBuilder(); | |
message_builder.AppendFormat( "- throw date: {0:o}", now ).AppendLine(); | |
message_builder.AppendFormat( "- helplink: \"{0}\"", e.HelpLink ).AppendLine(); | |
message_builder.AppendFormat( "- message: \"{0}\"", e.Message ).AppendLine(); | |
message_builder.AppendFormat( "- source: \"{0}\"", e.Source ).AppendLine(); | |
message_builder.AppendFormat( "- stack trace: \"{0}\"", e.StackTrace ).AppendLine(); | |
message_builder.AppendFormat( "- target site: \"{0}\"", e.TargetSite ); | |
innerLog( string.Format( "{0:x}.log", now.Ticks ), message_builder.ToString() ); | |
} | |
/// <summary> | |
/// | |
/// </summary> | |
/// <param name="filename"></param> | |
/// <param name="write_text"></param> | |
private static void innerLog(string filename, string write_text) { | |
using ( StreamWriter writer = new StreamWriter( File.Open( filename, | |
FileMode.OpenOrCreate | |
) | |
) | |
) { | |
writer.WriteLine( write_text ); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment