Merge pull request #37 from onerain88/ci

chore: namespace
oneRain 2020-03-04 15:33:11 +08:00 committed by GitHub
commit 638c43c4a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 # MFractors (Xamarin productivity tool) working folder
.mfractor/ .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 { namespace Common.Test {
public class AppRouterTest { public class AppRouterTest {
static void Print(LeanCloud.LogLevel level, string info) { static void Print(LogLevel level, string info) {
switch (level) { switch (level) {
case LeanCloud.LogLevel.Debug: case LogLevel.Debug:
TestContext.Out.WriteLine($"[DEBUG] {info}"); TestContext.Out.WriteLine($"[DEBUG] {info}");
break; break;
case LeanCloud.LogLevel.Warn: case LogLevel.Warn:
TestContext.Out.WriteLine($"[WARNING] {info}"); TestContext.Out.WriteLine($"[WARNING] {info}");
break; break;
case LeanCloud.LogLevel.Error: case LogLevel.Error:
TestContext.Out.WriteLine($"[ERROR] {info}"); TestContext.Out.WriteLine($"[ERROR] {info}");
break; break;
default: default:
@ -24,12 +24,12 @@ namespace Common.Test {
[SetUp] [SetUp]
public void SetUp() { public void SetUp() {
LeanCloud.Logger.LogDelegate += Print; Logger.LogDelegate += Print;
} }
[TearDown] [TearDown]
public void TearDown() { public void TearDown() {
LeanCloud.Logger.LogDelegate -= Print; Logger.LogDelegate -= Print;
} }
[Test] [Test]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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