move Log.cs from BizHawk.Emulation to BizHawk.Common
This commit is contained in:
parent
7f3f116cd9
commit
4f5d8b89c9
|
@ -3,6 +3,7 @@ using System.Text;
|
|||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
#pragma warning disable 162
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
<Compile Include="Buffer.cs" />
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="HawkFile.cs" />
|
||||
<Compile Include="Log.cs" />
|
||||
<Compile Include="MruStack.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="QuickCollections.cs" />
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace BizHawk.Common
|
||||
{
|
||||
public static class Log
|
||||
{
|
||||
static Log()
|
||||
{
|
||||
// You can set current desired logging settings here.
|
||||
// Production builds should be done with all logging disabled.
|
||||
LogToConsole = true;
|
||||
//LogToFile = true;
|
||||
//LogFilename = "d:/bizhawk.log";
|
||||
//EnableDomain("CD");
|
||||
//EnableDomain("CPU");
|
||||
//EnableDomain("VDC");
|
||||
//EnableDomain("MEM");
|
||||
}
|
||||
|
||||
// ============== Logging Domain Configuration ==============
|
||||
|
||||
private static List<string> EnabledLogDomains = new List<string>();
|
||||
|
||||
public static void EnableDomain(string domain)
|
||||
{
|
||||
if (EnabledLogDomains.Contains(domain) == false)
|
||||
EnabledLogDomains.Add(domain);
|
||||
}
|
||||
|
||||
public static void DisableDomain(string domain)
|
||||
{
|
||||
if (EnabledLogDomains.Contains(domain))
|
||||
EnabledLogDomains.Remove(domain);
|
||||
}
|
||||
|
||||
// ============== Logging Action Configuration ==============
|
||||
|
||||
public static Action<string> LogAction = DefaultLogger;
|
||||
|
||||
// NOTEs are only logged if the domain is enabled.
|
||||
// ERRORs are logged regardless.
|
||||
|
||||
public static void Note(string domain, string msg, params object[] vals)
|
||||
{
|
||||
if (EnabledLogDomains.Contains(domain))
|
||||
LogAction(String.Format(msg, vals));
|
||||
}
|
||||
|
||||
public static void Error(string domain, string msg, params object[] vals)
|
||||
{
|
||||
LogAction(String.Format(msg, vals));
|
||||
}
|
||||
|
||||
// ============== Default Logger Action ==============
|
||||
|
||||
public static Stream HACK_LOG_STREAM;
|
||||
|
||||
private static bool LogToConsole = false;
|
||||
private static bool LogToFile = false;
|
||||
|
||||
private static string LogFilename = "bizhawk.txt";
|
||||
private static StreamWriter writer;
|
||||
|
||||
private static void DefaultLogger(string message)
|
||||
{
|
||||
if (LogToConsole)
|
||||
Console.WriteLine(message);
|
||||
|
||||
if (LogToFile && writer == null)
|
||||
writer = new StreamWriter(LogFilename);
|
||||
|
||||
if (LogToFile)
|
||||
{
|
||||
writer.WriteLine(message);
|
||||
writer.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -477,7 +477,6 @@
|
|||
<Compile Include="Interfaces\IEmulator.cs" />
|
||||
<Compile Include="Interfaces\ISoundProvider.cs" />
|
||||
<Compile Include="Interfaces\IVideoProvider.cs" />
|
||||
<Compile Include="Log.cs" />
|
||||
<Compile Include="Consoles\PC Engine\Input.cs" />
|
||||
<Compile Include="Consoles\PC Engine\MemoryMap.cs" />
|
||||
<Compile Include="Consoles\PC Engine\MemoryMap.SF2.cs" />
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
{
|
||||
public partial class PCEngine
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
{
|
||||
public partial class PCEngine
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
{
|
||||
public partial class PCEngine
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
{
|
||||
public partial class PCEngine
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
{
|
||||
public partial class PCEngine
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Sega
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace BizHawk.Emulation.Consoles.Sega
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Sega
|
||||
{
|
||||
partial class Genesis
|
||||
{
|
||||
|
@ -116,7 +118,9 @@
|
|||
if (Controller["P1 Right"] == false) data |= 0x08;
|
||||
if (Controller["P1 B"] == false) data |= 0x10;
|
||||
if (Controller["P1 C"] == false) data |= 0x20;
|
||||
} else { // TH low
|
||||
}
|
||||
else
|
||||
{ // TH low
|
||||
if (Controller["P1 Up"] == false) data |= 0x01;
|
||||
if (Controller["P1 Down"] == false) data |= 0x02;
|
||||
if (Controller["P1 A"] == false) data |= 0x10;
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace BizHawk
|
||||
{
|
||||
public static class Log
|
||||
{
|
||||
static Log()
|
||||
{
|
||||
// You can set current desired logging settings here.
|
||||
// Production builds should be done with all logging disabled.
|
||||
LogToConsole = true;
|
||||
//LogToFile = true;
|
||||
//LogFilename = "d:/bizhawk.log";
|
||||
//EnableDomain("CD");
|
||||
//EnableDomain("CPU");
|
||||
//EnableDomain("VDC");
|
||||
//EnableDomain("MEM");
|
||||
}
|
||||
|
||||
// ============== Logging Domain Configuration ==============
|
||||
|
||||
private static List<string> EnabledLogDomains = new List<string>();
|
||||
|
||||
public static void EnableDomain(string domain)
|
||||
{
|
||||
if (EnabledLogDomains.Contains(domain) == false)
|
||||
EnabledLogDomains.Add(domain);
|
||||
}
|
||||
|
||||
public static void DisableDomain(string domain)
|
||||
{
|
||||
if (EnabledLogDomains.Contains(domain))
|
||||
EnabledLogDomains.Remove(domain);
|
||||
}
|
||||
|
||||
// ============== Logging Action Configuration ==============
|
||||
|
||||
public static Action<string> LogAction = DefaultLogger;
|
||||
|
||||
// NOTEs are only logged if the domain is enabled.
|
||||
// ERRORs are logged regardless.
|
||||
|
||||
public static void Note(string domain, string msg, params object[] vals)
|
||||
{
|
||||
if (EnabledLogDomains.Contains(domain))
|
||||
LogAction(String.Format(msg, vals));
|
||||
}
|
||||
|
||||
public static void Error(string domain, string msg, params object[] vals)
|
||||
{
|
||||
LogAction(String.Format(msg, vals));
|
||||
}
|
||||
|
||||
// ============== Default Logger Action ==============
|
||||
|
||||
public static Stream HACK_LOG_STREAM;
|
||||
|
||||
private static bool LogToConsole = false;
|
||||
private static bool LogToFile = false;
|
||||
|
||||
private static string LogFilename = "bizhawk.txt";
|
||||
private static StreamWriter writer;
|
||||
|
||||
private static void DefaultLogger(string message)
|
||||
{
|
||||
if (LogToConsole)
|
||||
Console.WriteLine(message);
|
||||
|
||||
if (LogToFile && writer == null)
|
||||
writer = new StreamWriter(LogFilename);
|
||||
|
||||
if (LogToFile)
|
||||
{
|
||||
writer.WriteLine(message);
|
||||
writer.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue