Skip to content

Commit 49fabbd

Browse files
committed
Merge pull request ServiceStack#156 from yeurch/spacification
Spacify ServiceStack.ServiceInterface assembly
2 parents 33570b2 + cd977d3 commit 49fabbd

File tree

124 files changed

+10153
-10152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+10153
-10152
lines changed

src/ServiceStack.ServiceInterface/Admin/RequestLogsFeature.cs

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -7,79 +7,79 @@
77

88
namespace ServiceStack.ServiceInterface.Admin
99
{
10-
public class RequestLogsFeature : IPlugin
11-
{
12-
/// <summary>
13-
/// RequestLogs service Route, default is /requestlogs
14-
/// </summary>
15-
public string AtRestPath { get; set; }
10+
public class RequestLogsFeature : IPlugin
11+
{
12+
/// <summary>
13+
/// RequestLogs service Route, default is /requestlogs
14+
/// </summary>
15+
public string AtRestPath { get; set; }
1616

17-
/// <summary>
18-
/// Turn On/Off Session Tracking
19-
/// </summary>
20-
public bool EnableSessionTracking { get; set; }
17+
/// <summary>
18+
/// Turn On/Off Session Tracking
19+
/// </summary>
20+
public bool EnableSessionTracking { get; set; }
2121

22-
/// <summary>
23-
/// Turn On/Off Tracking of Responses
24-
/// </summary>
25-
public bool EnableResponseTracking { get; set; }
22+
/// <summary>
23+
/// Turn On/Off Tracking of Responses
24+
/// </summary>
25+
public bool EnableResponseTracking { get; set; }
2626

27-
/// <summary>
28-
/// Turn On/Off Tracking of Exceptions
29-
/// </summary>
30-
public bool EnableErrorTracking { get; set; }
27+
/// <summary>
28+
/// Turn On/Off Tracking of Exceptions
29+
/// </summary>
30+
public bool EnableErrorTracking { get; set; }
3131

32-
/// <summary>
33-
/// Size of InMemoryRollingRequestLogger circular buffer
34-
/// </summary>
35-
public int? Capacity { get; set; }
32+
/// <summary>
33+
/// Size of InMemoryRollingRequestLogger circular buffer
34+
/// </summary>
35+
public int? Capacity { get; set; }
3636

37-
/// <summary>
38-
/// Limit access to /requestlogs service to these roles
39-
/// </summary>
40-
public string RequiresRole { get; set; }
37+
/// <summary>
38+
/// Limit access to /requestlogs service to these roles
39+
/// </summary>
40+
public string RequiresRole { get; set; }
4141

42-
/// <summary>
43-
/// Change the RequestLogger provider. Default is InMemoryRollingRequestLogger
44-
/// </summary>
45-
public IRequestLogger RequestLogger { get; set; }
42+
/// <summary>
43+
/// Change the RequestLogger provider. Default is InMemoryRollingRequestLogger
44+
/// </summary>
45+
public IRequestLogger RequestLogger { get; set; }
4646

47-
/// <summary>
48-
/// Don't log requests of these types. By default RequestLog's are excluded
49-
/// </summary>
50-
public Type[] ExcludeRequestDtoTypes { get; set; }
47+
/// <summary>
48+
/// Don't log requests of these types. By default RequestLog's are excluded
49+
/// </summary>
50+
public Type[] ExcludeRequestDtoTypes { get; set; }
5151

52-
/// <summary>
53-
/// Don't log request bodys for services with sensitive information.
54-
/// By default Auth and Registration requests are hidden.
55-
/// </summary>
56-
public Type[] HideRequestBodyForRequestDtoTypes { get; set; }
52+
/// <summary>
53+
/// Don't log request bodys for services with sensitive information.
54+
/// By default Auth and Registration requests are hidden.
55+
/// </summary>
56+
public Type[] HideRequestBodyForRequestDtoTypes { get; set; }
5757

58-
public RequestLogsFeature(int? capacity = null)
59-
{
60-
this.AtRestPath = "/requestlogs";
61-
this.Capacity = capacity;
62-
this.RequiresRole = RoleNames.Admin;
63-
this.EnableErrorTracking = true;
64-
this.ExcludeRequestDtoTypes = new[] { typeof(RequestLogs) };
65-
this.HideRequestBodyForRequestDtoTypes = new[] {
66-
typeof(Auth.Auth), typeof(Registration)
67-
};
68-
}
58+
public RequestLogsFeature(int? capacity = null)
59+
{
60+
this.AtRestPath = "/requestlogs";
61+
this.Capacity = capacity;
62+
this.RequiresRole = RoleNames.Admin;
63+
this.EnableErrorTracking = true;
64+
this.ExcludeRequestDtoTypes = new[] { typeof(RequestLogs) };
65+
this.HideRequestBodyForRequestDtoTypes = new[] {
66+
typeof(Auth.Auth), typeof(Registration)
67+
};
68+
}
6969

70-
public void Register(IAppHost appHost)
71-
{
72-
appHost.RegisterService<RequestLogsService>(AtRestPath);
70+
public void Register(IAppHost appHost)
71+
{
72+
appHost.RegisterService<RequestLogsService>(AtRestPath);
7373

74-
var requestLogger = RequestLogger ?? new InMemoryRollingRequestLogger(Capacity);
75-
requestLogger.EnableSessionTracking = EnableSessionTracking;
76-
requestLogger.EnableResponseTracking = EnableResponseTracking;
77-
requestLogger.EnableErrorTracking = EnableErrorTracking;
78-
requestLogger.RequiresRole = RequiresRole;
79-
requestLogger.ExcludeRequestDtoTypes = ExcludeRequestDtoTypes;
80-
requestLogger.HideRequestBodyForRequestDtoTypes = HideRequestBodyForRequestDtoTypes;
74+
var requestLogger = RequestLogger ?? new InMemoryRollingRequestLogger(Capacity);
75+
requestLogger.EnableSessionTracking = EnableSessionTracking;
76+
requestLogger.EnableResponseTracking = EnableResponseTracking;
77+
requestLogger.EnableErrorTracking = EnableErrorTracking;
78+
requestLogger.RequiresRole = RequiresRole;
79+
requestLogger.ExcludeRequestDtoTypes = ExcludeRequestDtoTypes;
80+
requestLogger.HideRequestBodyForRequestDtoTypes = HideRequestBodyForRequestDtoTypes;
8181

82-
appHost.Register(requestLogger);
83-
}
84-
}
82+
appHost.Register(requestLogger);
83+
}
84+
}
8585
}

src/ServiceStack.ServiceInterface/Admin/RequestLogsService.cs

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -6,105 +6,105 @@
66

77
namespace ServiceStack.ServiceInterface.Admin
88
{
9-
public class RequestLogs
10-
{
11-
public int? BeforeSecs { get; set; }
12-
public int? AfterSecs { get; set; }
13-
public string IpAddress { get; set; }
14-
public string ForwardedFor { get; set; }
15-
public string UserAuthId { get; set; }
16-
public string SessionId { get; set; }
17-
public string Referer { get; set; }
18-
public string PathInfo { get; set; }
19-
public long[] Ids { get; set; }
20-
public int? BeforeId { get; set; }
21-
public int? AfterId { get; set; }
22-
public bool? HasResponse { get; set; }
23-
public bool? WithErrors { get; set; }
24-
public int Skip { get; set; }
25-
public int? Take { get; set; }
26-
public bool? EnableSessionTracking { get; set; }
27-
public bool? EnableResponseTracking { get; set; }
28-
public bool? EnableErrorTracking { get; set; }
29-
}
9+
public class RequestLogs
10+
{
11+
public int? BeforeSecs { get; set; }
12+
public int? AfterSecs { get; set; }
13+
public string IpAddress { get; set; }
14+
public string ForwardedFor { get; set; }
15+
public string UserAuthId { get; set; }
16+
public string SessionId { get; set; }
17+
public string Referer { get; set; }
18+
public string PathInfo { get; set; }
19+
public long[] Ids { get; set; }
20+
public int? BeforeId { get; set; }
21+
public int? AfterId { get; set; }
22+
public bool? HasResponse { get; set; }
23+
public bool? WithErrors { get; set; }
24+
public int Skip { get; set; }
25+
public int? Take { get; set; }
26+
public bool? EnableSessionTracking { get; set; }
27+
public bool? EnableResponseTracking { get; set; }
28+
public bool? EnableErrorTracking { get; set; }
29+
}
3030

31-
public class RequestLogsResponse
32-
{
33-
public RequestLogsResponse()
34-
{
35-
this.Results = new List<RequestLogEntry>();
36-
}
31+
public class RequestLogsResponse
32+
{
33+
public RequestLogsResponse()
34+
{
35+
this.Results = new List<RequestLogEntry>();
36+
}
3737

38-
public List<RequestLogEntry> Results { get; set; }
39-
public Dictionary<string, string> Usage { get; set; }
40-
public ResponseStatus ResponseStatus { get; set; }
41-
}
38+
public List<RequestLogEntry> Results { get; set; }
39+
public Dictionary<string, string> Usage { get; set; }
40+
public ResponseStatus ResponseStatus { get; set; }
41+
}
4242

43-
public class RequestLogsService : ServiceBase<RequestLogs>
44-
{
45-
private static readonly Dictionary<string,string> Usage = new Dictionary<string,string> {
46-
{"int BeforeSecs", "Requests before elapsed time"},
47-
{"int AfterSecs", "Requests after elapsed time"},
48-
{"string IpAddress", "Requests matching Ip Address"},
49-
{"string ForwardedFor", "Requests matching Forwarded Ip Address"},
50-
{"string UserAuthId", "Requests matching UserAuthId"},
51-
{"string SessionId", "Requests matching SessionId"},
52-
{"string Referer", "Requests matching Http Referer"},
53-
{"string PathInfo", "Requests matching PathInfo"},
54-
{"int BeforeId", "Requests before RequestLog Id"},
55-
{"int AfterId", "Requests after RequestLog Id"},
56-
{"bool WithErrors", "Requests with errors"},
57-
{"int Skip", "Skip past N results"},
58-
{"int Take", "Only look at last N results"},
59-
{"bool EnableSessionTracking", "Turn On/Off Session Tracking"},
60-
{"bool EnableResponseTracking", "Turn On/Off Tracking of Responses"},
61-
{"bool EnableErrorTracking", "Turn On/Off Tracking of Errors"},
62-
};
43+
public class RequestLogsService : ServiceBase<RequestLogs>
44+
{
45+
private static readonly Dictionary<string,string> Usage = new Dictionary<string,string> {
46+
{"int BeforeSecs", "Requests before elapsed time"},
47+
{"int AfterSecs", "Requests after elapsed time"},
48+
{"string IpAddress", "Requests matching Ip Address"},
49+
{"string ForwardedFor", "Requests matching Forwarded Ip Address"},
50+
{"string UserAuthId", "Requests matching UserAuthId"},
51+
{"string SessionId", "Requests matching SessionId"},
52+
{"string Referer", "Requests matching Http Referer"},
53+
{"string PathInfo", "Requests matching PathInfo"},
54+
{"int BeforeId", "Requests before RequestLog Id"},
55+
{"int AfterId", "Requests after RequestLog Id"},
56+
{"bool WithErrors", "Requests with errors"},
57+
{"int Skip", "Skip past N results"},
58+
{"int Take", "Only look at last N results"},
59+
{"bool EnableSessionTracking", "Turn On/Off Session Tracking"},
60+
{"bool EnableResponseTracking", "Turn On/Off Tracking of Responses"},
61+
{"bool EnableErrorTracking", "Turn On/Off Tracking of Errors"},
62+
};
6363

64-
protected override object Run(RequestLogs request)
65-
{
66-
if (RequestLogger == null)
67-
throw new Exception("No IRequestLogger is registered");
64+
protected override object Run(RequestLogs request)
65+
{
66+
if (RequestLogger == null)
67+
throw new Exception("No IRequestLogger is registered");
6868

69-
RequiredRoleAttribute.AssertRequiredRoles(RequestContext, RequestLogger.RequiresRole);
70-
71-
if (request.EnableSessionTracking.HasValue)
72-
RequestLogger.EnableSessionTracking = request.EnableSessionTracking.Value;
69+
RequiredRoleAttribute.AssertRequiredRoles(RequestContext, RequestLogger.RequiresRole);
70+
71+
if (request.EnableSessionTracking.HasValue)
72+
RequestLogger.EnableSessionTracking = request.EnableSessionTracking.Value;
7373

74-
var now = DateTime.UtcNow;
75-
var logs = RequestLogger.GetLatestLogs(request.Take).AsQueryable();
74+
var now = DateTime.UtcNow;
75+
var logs = RequestLogger.GetLatestLogs(request.Take).AsQueryable();
7676

77-
if (request.BeforeSecs.HasValue)
78-
logs = logs.Where(x => (now - x.DateTime) <= TimeSpan.FromSeconds(request.BeforeSecs.Value));
79-
if (request.AfterSecs.HasValue)
80-
logs = logs.Where(x => (now - x.DateTime) > TimeSpan.FromSeconds(request.AfterSecs.Value));
81-
if (!request.IpAddress.IsNullOrEmpty())
82-
logs = logs.Where(x => x.IpAddress == request.IpAddress);
83-
if (!request.UserAuthId.IsNullOrEmpty())
84-
logs = logs.Where(x => x.UserAuthId == request.UserAuthId);
85-
if (!request.SessionId.IsNullOrEmpty())
86-
logs = logs.Where(x => x.SessionId == request.SessionId);
87-
if (!request.Referer.IsNullOrEmpty())
88-
logs = logs.Where(x => x.Referer == request.Referer);
89-
if (!request.PathInfo.IsNullOrEmpty())
90-
logs = logs.Where(x => x.PathInfo == request.PathInfo);
91-
if (!request.Ids.IsEmpty())
92-
logs = logs.Where(x => request.Ids.Contains(x.Id));
93-
if (request.BeforeId.HasValue)
94-
logs = logs.Where(x => x.Id <= request.BeforeId);
95-
if (request.AfterId.HasValue)
96-
logs = logs.Where(x => x.Id > request.AfterId);
97-
if (request.WithErrors.HasValue)
98-
logs = request.WithErrors.Value
99-
? logs.Where(x => x.ErrorResponse != null)
100-
: logs.Where(x => x.ErrorResponse == null);
77+
if (request.BeforeSecs.HasValue)
78+
logs = logs.Where(x => (now - x.DateTime) <= TimeSpan.FromSeconds(request.BeforeSecs.Value));
79+
if (request.AfterSecs.HasValue)
80+
logs = logs.Where(x => (now - x.DateTime) > TimeSpan.FromSeconds(request.AfterSecs.Value));
81+
if (!request.IpAddress.IsNullOrEmpty())
82+
logs = logs.Where(x => x.IpAddress == request.IpAddress);
83+
if (!request.UserAuthId.IsNullOrEmpty())
84+
logs = logs.Where(x => x.UserAuthId == request.UserAuthId);
85+
if (!request.SessionId.IsNullOrEmpty())
86+
logs = logs.Where(x => x.SessionId == request.SessionId);
87+
if (!request.Referer.IsNullOrEmpty())
88+
logs = logs.Where(x => x.Referer == request.Referer);
89+
if (!request.PathInfo.IsNullOrEmpty())
90+
logs = logs.Where(x => x.PathInfo == request.PathInfo);
91+
if (!request.Ids.IsEmpty())
92+
logs = logs.Where(x => request.Ids.Contains(x.Id));
93+
if (request.BeforeId.HasValue)
94+
logs = logs.Where(x => x.Id <= request.BeforeId);
95+
if (request.AfterId.HasValue)
96+
logs = logs.Where(x => x.Id > request.AfterId);
97+
if (request.WithErrors.HasValue)
98+
logs = request.WithErrors.Value
99+
? logs.Where(x => x.ErrorResponse != null)
100+
: logs.Where(x => x.ErrorResponse == null);
101101

102-
var results = logs.Skip(request.Skip).OrderByDescending(x => x.Id).ToList();
102+
var results = logs.Skip(request.Skip).OrderByDescending(x => x.Id).ToList();
103103

104-
return new RequestLogsResponse {
105-
Results = results,
106-
Usage = Usage,
107-
};
108-
}
109-
}
104+
return new RequestLogsResponse {
105+
Results = results,
106+
Usage = Usage,
107+
};
108+
}
109+
}
110110
}

0 commit comments

Comments
 (0)