-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLog.Books.cs
More file actions
175 lines (153 loc) · 6.22 KB
/
Log.Books.cs
File metadata and controls
175 lines (153 loc) · 6.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
using Microsoft.Extensions.Logging;
namespace BookStore.ApiService.Infrastructure.Logging;
/// <summary>
/// Book-related log messages for CRUD operations, validation, and queries.
/// </summary>
public static partial class Log
{
public static partial class Books
{
// Creation
[LoggerMessage(
Level = LogLevel.Information,
Message = "Creating book: Id={BookId}, Title={Title}, CorrelationId={CorrelationId}")]
public static partial void BookCreating(
ILogger logger,
Guid bookId,
string title,
string correlationId);
[LoggerMessage(
Level = LogLevel.Information,
Message = "Book created successfully: Id={BookId}, Title={Title}")]
public static partial void BookCreated(
ILogger logger,
Guid bookId,
string title);
// Update
[LoggerMessage(
Level = LogLevel.Information,
Message = "Updating book: Id={BookId}, Title={Title}, Version={Version}")]
public static partial void BookUpdating(
ILogger logger,
Guid bookId,
string title,
long version);
[LoggerMessage(
Level = LogLevel.Information,
Message = "Book updated successfully: Id={BookId}")]
public static partial void BookUpdated(ILogger logger, Guid bookId);
// Soft Delete
[LoggerMessage(
Level = LogLevel.Information,
Message = "Soft deleting book: Id={BookId}")]
public static partial void BookSoftDeleting(ILogger logger, Guid bookId);
[LoggerMessage(
Level = LogLevel.Information,
Message = "Book soft deleted successfully: Id={BookId}")]
public static partial void BookSoftDeleted(ILogger logger, Guid bookId);
// Restore
[LoggerMessage(
Level = LogLevel.Information,
Message = "Restoring book: Id={BookId}")]
public static partial void BookRestoring(ILogger logger, Guid bookId);
[LoggerMessage(
Level = LogLevel.Information,
Message = "Book restored successfully: Id={BookId}")]
public static partial void BookRestored(ILogger logger, Guid bookId);
// Validation Errors
[LoggerMessage(
Level = LogLevel.Warning,
Message = "Invalid language code for book: BookId={BookId}, LanguageCode={LanguageCode}")]
public static partial void InvalidLanguageCode(
ILogger logger,
Guid bookId,
string languageCode);
[LoggerMessage(
Level = LogLevel.Warning,
Message = "Invalid translation language codes for book: BookId={BookId}, InvalidCodes={InvalidCodes}")]
public static partial void InvalidTranslationCodes(
ILogger logger,
Guid bookId,
string invalidCodes);
[LoggerMessage(
Level = LogLevel.Warning,
Message = "Missing default language translation for book: BookId={BookId}, DefaultLanguage={DefaultLanguage}")]
public static partial void MissingDefaultTranslation(
ILogger logger,
Guid bookId,
string defaultLanguage);
[LoggerMessage(
Level = LogLevel.Warning,
Message = "Description too long for book: BookId={BookId}, LanguageCode={LanguageCode}, MaxLength={MaxLength}, ActualLength={ActualLength}")]
public static partial void DescriptionTooLong(
ILogger logger,
Guid bookId,
string languageCode,
int maxLength,
int actualLength);
// ETag Validation
[LoggerMessage(
Level = LogLevel.Warning,
Message = "ETag mismatch for book: Id={BookId}, Expected={ExpectedETag}, Provided={ProvidedETag}")]
public static partial void ETagMismatch(
ILogger logger,
Guid bookId,
string expectedETag,
string providedETag);
// Not Found
[LoggerMessage(
Level = LogLevel.Warning,
Message = "Book not found: Id={BookId}")]
public static partial void BookNotFound(ILogger logger, Guid bookId);
// Query Operations
[LoggerMessage(
Level = LogLevel.Debug,
Message = "Searching books: SearchTerm={SearchTerm}, Page={Page}, PageSize={PageSize}")]
public static partial void SearchingBooks(
ILogger logger,
string? searchTerm,
int page,
int pageSize);
[LoggerMessage(
Level = LogLevel.Debug,
Message = "Books search completed: ResultCount={ResultCount}, TotalCount={TotalCount}")]
public static partial void SearchCompleted(
ILogger logger,
int resultCount,
int totalCount);
[LoggerMessage(
Level = LogLevel.Debug,
Message = "Retrieving book: Id={BookId}")]
public static partial void RetrievingBook(ILogger logger, Guid bookId);
// Domain Validation Errors
[LoggerMessage(
Level = LogLevel.Warning,
Message = "Invalid book data: BookId={BookId}, Error={Error}")]
public static partial void InvalidBookData(
ILogger logger,
Guid bookId,
string error);
[LoggerMessage(
Level = LogLevel.Warning,
Message = "Invalid book operation: BookId={BookId}, Error={Error}")]
public static partial void InvalidBookOperation(
ILogger logger,
Guid bookId,
string error);
// Discount Operations
[LoggerMessage(
Level = LogLevel.Error,
Message = "Failed to apply discount to book: BookId={BookId}, Error={Error}")]
public static partial void ApplyDiscountFailed(
ILogger logger,
Guid bookId,
string error);
[LoggerMessage(
Level = LogLevel.Error,
Message = "Failed to remove discount from book: BookId={BookId}, Error={Error}")]
public static partial void RemoveDiscountFailed(
ILogger logger,
Guid bookId,
string error);
}
}