1+ /**
2+ * Descriptions for each LogStruct enum class
3+ * These are used in the documentation to explain what each enum is for
4+ */
5+ export const ENUM_DESCRIPTIONS : Record < string , string > = {
6+ "LogStruct::LogLevel" : "Log severity levels for different types of log messages" ,
7+ "LogStruct::Source" : "Sources of log messages to identify which part of the system generated them" ,
8+ "LogStruct::LogEvent" : "Event types for different kinds of operations and activities" ,
9+ "LogStruct::ErrorHandlingMode" : "Error handling strategies for different types of errors"
10+ } ;
11+
12+ /**
13+ * Get the description for an enum class
14+ * @param enumName The full name of the enum class (e.g., "LogStruct::LogLevel")
15+ * @returns The description of the enum
16+ * @throws Error if no description is found for the enum
17+ */
18+ export function getEnumDescription ( enumName : string ) : string {
19+ const description = ENUM_DESCRIPTIONS [ enumName ] ;
20+ if ( ! description ) {
21+ throw new Error ( `No description found for enum: ${ enumName } ` ) ;
22+ }
23+ return description ;
24+ }
25+
26+ /**
27+ * Value descriptions for specific enum values
28+ * These provide context for what each enum value means
29+ */
30+ export const ENUM_VALUE_DESCRIPTIONS : Record < string , Record < string , string > > = {
31+ "LogStruct::LogLevel" : {
32+ "Debug" : "Detailed debugging information" ,
33+ "Info" : "General informational messages" ,
34+ "Warn" : "Warning conditions that should be noted" ,
35+ "Error" : "Error conditions that affect operation" ,
36+ "Fatal" : "Severe error conditions that cause the application to terminate" ,
37+ "Unknown" : "Used when a log level cannot be determined"
38+ } ,
39+ "LogStruct::Source" : {
40+ "Rails" : "Core Rails framework components" ,
41+ "App" : "Application-specific code" ,
42+ "Job" : "Background job processing" ,
43+ "Mailer" : "Email delivery and processing" ,
44+ "Security" : "Security-related events and checks" ,
45+ "TypeChecking" : "Type checking errors (Sorbet)" ,
46+ "LogStruct" : "Errors from LogStruct itself" ,
47+ "Storage" : "ActiveStorage logs and errors" ,
48+ "Shrine" : "Shrine file upload logs and errors" ,
49+ "CarrierWave" : "CarrierWave file upload logs and errors" ,
50+ "Sidekiq" : "Sidekiq background job logs and errors"
51+ } ,
52+ "LogStruct::ErrorHandlingMode" : {
53+ "Ignore" : "Completely ignore errors" ,
54+ "Log" : "Log errors but don't report them" ,
55+ "LogProduction" : "Log in production, raise in development" ,
56+ "Report" : "Log and report errors to error service" ,
57+ "ReportProduction" : "Report in production without crashing, raise during dev/test" ,
58+ "Raise" : "Always raise the error (reported by tracking service)"
59+ } ,
60+ "LogStruct::LogEvent" : {
61+ "Log" : "Standard log message" ,
62+ "Request" : "HTTP request" ,
63+ "Enqueue" : "Job added to queue" ,
64+ "Schedule" : "Job scheduled for future processing" ,
65+ "Start" : "Job processing started" ,
66+ "Finish" : "Job processing completed" ,
67+ "Upload" : "File upload operation" ,
68+ "Download" : "File download operation" ,
69+ "Delete" : "File deletion operation" ,
70+ "Metadata" : "File metadata operation" ,
71+ "Exist" : "File existence check operation" ,
72+ "Stream" : "File streaming operation" ,
73+ "Url" : "File URL generation operation" ,
74+ "Delivery" : "Email preparation for delivery" ,
75+ "Delivered" : "Email successfully delivered" ,
76+ "IPSpoof" : "IP spoofing attack attempt" ,
77+ "CSRFViolation" : "Cross-Site Request Forgery violation" ,
78+ "BlockedHost" : "Access attempt from blocked host" ,
79+ "Error" : "Error occurrence" ,
80+ "Unknown" : "Unclassified event type"
81+ }
82+ } ;
83+
84+ /**
85+ * Get the description for a specific enum value
86+ * @param enumName The full name of the enum class (e.g., "LogStruct::LogLevel")
87+ * @param valueName The name of the enum value (e.g., "Debug")
88+ * @returns The description of the enum value
89+ * @throws Error if no description is found for the enum value
90+ */
91+ export function getEnumValueDescription ( enumName : string , valueName : string ) : string {
92+ const enumValues = ENUM_VALUE_DESCRIPTIONS [ enumName ] ;
93+ if ( ! enumValues ) {
94+ throw new Error ( `No values found for enum: ${ enumName } ` ) ;
95+ }
96+
97+ const description = enumValues [ valueName ] ;
98+ if ( ! description ) {
99+ throw new Error ( `No description found for enum value: ${ enumName } ::${ valueName } ` ) ;
100+ }
101+
102+ return description ;
103+ }
0 commit comments