chore: namespace

oneRain 2020-03-04 15:17:53 +08:00
parent 9384784201
commit bfcd2b4379
15 changed files with 78 additions and 6 deletions

2
.gitignore vendored
View File

@ -328,3 +328,5 @@ ASALocalRun/
# MFractors (Xamarin productivity tool) working folder
.mfractor/
!Common/Log/

19
Common/Log/LogLevel.cs Normal file
View File

@ -0,0 +1,19 @@
namespace LeanCloud.Common {
/// <summary>
/// 日志级别
/// </summary>
public enum LogLevel {
/// <summary>
/// 调试级别
/// </summary>
Debug,
/// <summary>
/// 警告级别
/// </summary>
Warn,
/// <summary>
/// 错误级别
/// </summary>
Error,
}
}

40
Common/Log/Logger.cs Normal file
View File

@ -0,0 +1,40 @@
using System;
namespace LeanCloud.Common {
/// <summary>
/// 日志类
/// </summary>
public static class Logger {
/// <summary>
/// 日志回调接口,方便开发者调试
/// </summary>
/// <value>The log delegate.</value>
public static Action<LogLevel, string> LogDelegate {
get; set;
}
public static void Debug(string log) {
LogDelegate?.Invoke(LogLevel.Debug, log);
}
public static void Debug(string format, params object[] args) {
LogDelegate?.Invoke(LogLevel.Debug, string.Format(format, args));
}
public static void Warn(string log) {
LogDelegate?.Invoke(LogLevel.Warn, log);
}
public static void Warn(string format, params object[] args) {
LogDelegate?.Invoke(LogLevel.Warn, string.Format(format, args));
}
public static void Error(string log) {
LogDelegate?.Invoke(LogLevel.Error, log);
}
public static void Error(string format, params object[] args) {
LogDelegate?.Invoke(LogLevel.Error, string.Format(format, args));
}
}
}

View File

@ -5,15 +5,15 @@ using LeanCloud.Common;
namespace Common.Test {
public class AppRouterTest {
static void Print(LeanCloud.LogLevel level, string info) {
static void Print(LogLevel level, string info) {
switch (level) {
case LeanCloud.LogLevel.Debug:
case LogLevel.Debug:
TestContext.Out.WriteLine($"[DEBUG] {info}");
break;
case LeanCloud.LogLevel.Warn:
case LogLevel.Warn:
TestContext.Out.WriteLine($"[WARNING] {info}");
break;
case LeanCloud.LogLevel.Error:
case LogLevel.Error:
TestContext.Out.WriteLine($"[ERROR] {info}");
break;
default:
@ -24,12 +24,12 @@ namespace Common.Test {
[SetUp]
public void SetUp() {
LeanCloud.Logger.LogDelegate += Print;
Logger.LogDelegate += Print;
}
[TearDown]
public void TearDown() {
LeanCloud.Logger.LogDelegate -= Print;
Logger.LogDelegate -= Print;
}
[Test]

View File

@ -1,6 +1,7 @@
using NUnit.Framework;
using System.Threading.Tasks;
using LeanCloud.Storage;
using LeanCloud.Common;
namespace LeanCloud.Test {
public class ACLTest {

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using LeanCloud.Storage;
using LeanCloud.Common;
namespace LeanCloud.Test {
public class CloudTest {

View File

@ -1,5 +1,6 @@
using NUnit.Framework;
using LeanCloud.Storage;
using LeanCloud.Common;
namespace LeanCloud.Test {
public class ExceptionTest {

View File

@ -3,6 +3,7 @@ using System;
using System.Text;
using System.Threading.Tasks;
using LeanCloud.Storage;
using LeanCloud.Common;
namespace LeanCloud.Test {
public class FileTest {

View File

@ -3,6 +3,7 @@ using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using LeanCloud.Storage;
using LeanCloud.Common;
namespace LeanCloud.Test {
public class ObjectTest {

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LeanCloud.Storage;
using LeanCloud.Common;
namespace LeanCloud.Test {
public class OperationTest {

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LeanCloud.Storage;
using LeanCloud.Common;
namespace LeanCloud.Test {
public class QueryTest {

View File

@ -3,6 +3,7 @@ using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using LeanCloud.Storage;
using LeanCloud.Common;
namespace LeanCloud.Test {
public class RelationTest {

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using LeanCloud.Storage;
using LeanCloud.Common;
namespace LeanCloud.Test {
[TestFixture]

View File

@ -2,6 +2,7 @@
using System.Threading.Tasks;
using System.Collections.Generic;
using LeanCloud.Storage;
using LeanCloud.Common;
namespace LeanCloud.Test {
internal class Hello : LCObject {

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LeanCloud.Storage;
using LeanCloud.Common;
namespace LeanCloud.Test {
public class UserTest {