-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHaliteHelper.cs
44 lines (39 loc) · 1.04 KB
/
HaliteHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.IO;
namespace Halite
{
/// <summary>
/// Helper methods
/// </summary>
public static class ExtensionMethods
{
public static int Mod(this int number, int mod)
{
return (number % mod + mod) % mod;
}
}
/// <summary>
/// Helpful for debugging.
/// </summary>
public static class Log
{
private static string _logPath;
/// <summary>
/// File must exist
/// </summary>
public static void Setup(string logPath)
{
_logPath = logPath;
}
public static void Information(string message)
{
if (!string.IsNullOrEmpty(_logPath))
File.AppendAllLines(_logPath,
new[] {string.Format("{0}: {1}", DateTime.Now.ToShortTimeString(), message)});
}
public static void Error(Exception exception)
{
Log.Information(string.Format("ERROR: {0} {1}", exception.Message, exception.StackTrace));
}
}
}