Skip to content

Commit ed053f5

Browse files
committed
Remove log4net
1 parent eda9f56 commit ed053f5

5 files changed

Lines changed: 37 additions & 19 deletions

File tree

FrappeRestClient.Net/Db.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
// Copyright (c) PlaceholderCompany. All rights reserved.
33
// </copyright>
44

5-
namespace Frappe.Net
5+
namespace FrappeRestClient.Net
66
{
77
using System;
88
using System.Collections.Generic;
9+
using System.Diagnostics;
910
using System.Threading.Tasks;
10-
using log4net;
1111
using Newtonsoft.Json;
1212
using Newtonsoft.Json.Linq;
1313
using Tiny.RestClient;
@@ -31,7 +31,6 @@ namespace Frappe.Net
3131
public class Db : JsonObjectParser
3232
{
3333
private const string RESOURCEPATH = "/";
34-
private static readonly ILog log = LogManager.GetLogger(typeof(Db));
3534
private FrappeRestClient frappe;
3635
private TinyRestClient client;
3736

@@ -113,7 +112,7 @@ public async Task<dynamic> GetListAsync(string doctype, string[] fields = null,
113112
}
114113
catch (Exception e)
115114
{
116-
log.Error(e.Message);
115+
Debug.WriteLine(e.Message);
117116
throw;
118117
}
119118

@@ -245,7 +244,7 @@ public async Task<string> GetValueAsync(string doctype, string fieldName = null,
245244
}
246245
catch (Exception e)
247246
{
248-
log.Error(e.Message);
247+
Debug.WriteLine(e.Message);
249248
throw;
250249
}
251250

@@ -274,7 +273,7 @@ public async Task<string> GetSingleValueAsync(string doctype, string field)
274273
}
275274
catch (Exception e)
276275
{
277-
log.Error(e.Message);
276+
Debug.WriteLine(e.Message);
278277
throw;
279278
}
280279

@@ -389,15 +388,15 @@ public async Task<dynamic> SaveAsync(dynamic doc)
389388
}
390389
catch (HttpException e)
391390
{
392-
log.Error($"{e.StatusCode} : {e.Message}");
391+
Debug.WriteLine($"{e.StatusCode} : {e.Message}");
393392
if (e.StatusCode == System.Net.HttpStatusCode.ExpectationFailed)
394393
{
395394
throw new InvalidOperationException("Document not saved");
396395
}
397396
}
398397
catch (Exception e)
399398
{
400-
log.Error(e.Message);
399+
Debug.WriteLine(e.Message);
401400
}
402401

403402
this.frappe.ResetRoute();
@@ -428,7 +427,7 @@ public async Task<string> RenameDocAsync(string doctype, string oldName, string
428427
}
429428
catch (HttpException e)
430429
{
431-
log.Error($"{e.StatusCode} : {e.Message}");
430+
Debug.WriteLine($"{e.StatusCode} : {e.Message}");
432431
if (e.StatusCode == System.Net.HttpStatusCode.ExpectationFailed)
433432
{
434433
throw new InvalidOperationException("Unable to rename document");
@@ -577,7 +576,7 @@ public async Task<dynamic> AttachFileAsync(string fileName, byte[] fileData, str
577576
}
578577
catch (Exception e)
579578
{
580-
log.Error(e.Message);
579+
Debug.WriteLine(e.Message);
581580
throw;
582581
}
583582

FrappeRestClient.Net/FrappeRestClient.Net.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
2626
<Version>1.0.1</Version>
2727
<DocumentationFile>C:\Users\aking\source\repos\Frappe.Net\src\FrappeRestClient.Net\Frappe.Net.xml</DocumentationFile>
28+
<PackageReleaseNotes>RELEASE-NOTES.MD</PackageReleaseNotes>
2829
</PropertyGroup>
2930

3031
<ItemGroup>

FrappeRestClient.Net/FrappeRestClient.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22
// Copyright (c) Yemi Kudaisi. All rights reserved.
33
// </copyright>
44

5-
namespace Frappe.Net
5+
namespace FrappeRestClient.Net
66
{
77
using System;
88
using System.Collections.Generic;
9+
using System.Diagnostics;
910
using System.Linq;
1011
using System.Net.Http;
1112
using System.Security.Authentication;
1213
using System.Threading.Tasks;
1314
using global::FrappeRestClient.Net;
1415
using global::FrappeRestClient.Net.Authorization;
15-
using log4net;
16-
using log4net.Config;
1716
using Tiny.RestClient;
1817

1918
/// <summary>
@@ -22,7 +21,6 @@ namespace Frappe.Net
2221
/// </summary>
2322
public class FrappeRestClient : JsonObjectParser
2423
{
25-
private static readonly ILog Log = LogManager.GetLogger(typeof(FrappeRestClient));
2624
private string baseUrl;
2725
private TinyRestClient client;
2826
private bool isAuthenticated;
@@ -48,7 +46,6 @@ public FrappeRestClient(string baseUrl, bool debug = false)
4846

4947
this.db = new Db(this);
5048
this.LoginCookies = EmptyLoginCookies;
51-
BasicConfigurator.Configure();
5249
}
5350

5451
/// <summary>
@@ -67,6 +64,11 @@ public FrappeRestClient(string baseUrl, bool debug = false)
6764
/// <see cref="TinyRestClient"/>
6865
public TinyRestClient Client { get => this.client; set => this.client = value; }
6966

67+
/// <summary>
68+
/// Gets or sets the session cookiers generated on login.
69+
/// </summary>
70+
public IDictionary<string, string> LoginCookies { get => this.loginCookies; set => this.loginCookies = value; }
71+
7072
private static IDictionary<string, string> EmptyLoginCookies
7173
{
7274
get
@@ -82,8 +84,6 @@ private static IDictionary<string, string> EmptyLoginCookies
8284
}
8385
}
8486

85-
public IDictionary<string, string> LoginCookies { get => loginCookies; set => loginCookies = value; }
86-
8787
/// <summary>
8888
/// Changes the route from the default route
8989
/// to supplied route.
@@ -229,7 +229,7 @@ public async Task<IDictionary<string, string>> UsePasswordAsync(string email, st
229229
if (e.StatusCode == System.Net.HttpStatusCode.Unauthorized)
230230
{
231231
var msg = "Invalid login credential";
232-
Log.Error($"{msg} >>> {e.Message}");
232+
Debug.WriteLine($"{msg} >>> {e.Message}");
233233
throw new AuthenticationException();
234234
}
235235

FrappeRestClient.Net/JsonObjectParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Copyright (c) Yemi Kudaisi. All rights reserved.
33
// </copyright>
44

5-
namespace Frappe.Net
5+
namespace FrappeRestClient.Net
66
{
77
using Newtonsoft.Json.Linq;
88

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# v1.0.2.2
2+
3+
- Removed log4net.
4+
# v1.0.2.1
5+
6+
- Migrated to .Net Standard 2.0.
7+
8+
# v1.0.2
9+
10+
- Downgraded to support .Net Core 2.0 for more compatibility.
11+
12+
# v1.0.1
13+
14+
- Added access to cookies when logged in with password.
15+
16+
# v1.0.0
17+
18+
- Initial release.

0 commit comments

Comments
 (0)