mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Use runtime instead of compile-time conditionals for result logging
This commit is contained in:
parent
47f2f4954a
commit
2b828bb50f
2 changed files with 18 additions and 7 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -265,3 +265,4 @@ __pycache__/
|
||||||
global.json
|
global.json
|
||||||
|
|
||||||
!tests/LibHac.Tests/CryptoTests/TestVectors/*
|
!tests/LibHac.Tests/CryptoTests/TestVectors/*
|
||||||
|
**/DisasmoBin/
|
||||||
|
|
|
@ -42,9 +42,8 @@ namespace LibHac
|
||||||
/// <returns>The called <see cref="Result"/> value.</returns>
|
/// <returns>The called <see cref="Result"/> value.</returns>
|
||||||
public Result Log()
|
public Result Log()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
LogImpl();
|
||||||
LogCallback?.Invoke(this);
|
|
||||||
#endif
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,12 +54,23 @@ namespace LibHac
|
||||||
/// <returns>The called <see cref="Result"/> value.</returns>
|
/// <returns>The called <see cref="Result"/> value.</returns>
|
||||||
public Result LogConverted(Result originalResult)
|
public Result LogConverted(Result originalResult)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
LogConvertedImpl(originalResult);
|
||||||
ConvertedLogCallback?.Invoke(this, originalResult);
|
|
||||||
#endif
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Conditional("DEBUG")]
|
||||||
|
private void LogImpl()
|
||||||
|
{
|
||||||
|
LogCallback?.Invoke(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Conditional("DEBUG")]
|
||||||
|
private void LogConvertedImpl(Result originalResult)
|
||||||
|
{
|
||||||
|
ConvertedLogCallback?.Invoke(this, originalResult);
|
||||||
|
}
|
||||||
|
|
||||||
public delegate void ResultLogger(Result result);
|
public delegate void ResultLogger(Result result);
|
||||||
public delegate void ConvertedResultLogger(Result result, Result originalResult);
|
public delegate void ConvertedResultLogger(Result result, Result originalResult);
|
||||||
public delegate bool ResultNameGetter(Result result, out string name);
|
public delegate bool ResultNameGetter(Result result, out string name);
|
||||||
|
|
Loading…
Reference in a new issue