-
-
Notifications
You must be signed in to change notification settings - Fork 232
Expand file tree
/
Copy pathLoggerParameter.cls
More file actions
868 lines (805 loc) · 41.8 KB
/
LoggerParameter.cls
File metadata and controls
868 lines (805 loc) · 41.8 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
//------------------------------------------------------------------------------------------------//
// This file is part of the Nebula Logger project, released under the MIT License. //
// See LICENSE file or go to https://github.com/jongpie/NebulaLogger for full license details. //
//------------------------------------------------------------------------------------------------//
/**
* @group Configuration
* @description Provides a centralized way to load parameters for SObject handlers & plugins,
* and casts the parameters to common data types
*/
@SuppressWarnings('PMD.CognitiveComplexity, PMD.CyclomaticComplexity, PMD.ExcessivePublicCount, PMD.PropertyNamingConventions')
public class LoggerParameter {
/**
* @description Indicates if Nebula Logger will make an async callout to `https://api.status.salesforce.com`
* to get additional details about the current org, which is then stored on the Log__c record.
* Controlled by the custom metadata record `LoggerParameter.CallStatusApi`, or `false` as the default
*/
public static final Boolean CALL_STATUS_API {
get {
if (CALL_STATUS_API == null) {
CALL_STATUS_API = getBoolean('CallStatusApi', false);
}
return CALL_STATUS_API;
}
private set;
}
/**
* @description The name of the `LogEntry__c` field set to use as the default field set when configuring
* the LWC `<c-related-log-entries>` within App Builder.
* Controlled by the custom metadata record `LoggerParameter.DefaultLogEntryRelatedListFieldSet`,
* or `Related_List_Defaults` as the default
*/
public static final String DEFAULT_LOG_ENTRY_RELATED_LIST_FIELD_SET {
get {
if (DEFAULT_LOG_ENTRY_RELATED_LIST_FIELD_SET == null) {
String configuredValue = getString('DefaultLogEntryRelatedListFieldSet', 'Related_List_Defaults');
DEFAULT_LOG_ENTRY_RELATED_LIST_FIELD_SET = String.isNotBlank(configuredValue) ? configuredValue : '';
}
return DEFAULT_LOG_ENTRY_RELATED_LIST_FIELD_SET;
}
private set;
}
/**
* @description Indicates if Nebula Logger's LWC `logEntryEventStream` is enabled. The component uses
* the Emp API, which counts towards orgs' daily delivery allocations for platform events.
* To help reduce usage of the daily allocation limit, orgs can disable the LWC.
* Controlled by the custom metadata record `LoggerParameter.EnableLogEntryEventStream`,
* or `true` as the default
*/
public static final Boolean ENABLE_LOG_ENTRY_EVENT_STREAM {
get {
if (ENABLE_LOG_ENTRY_EVENT_STREAM == null) {
ENABLE_LOG_ENTRY_EVENT_STREAM = getBoolean('EnableLogEntryEventStream', true);
}
return ENABLE_LOG_ENTRY_EVENT_STREAM;
}
private set;
}
/**
* @description Indicates if Nebula Logger will parse a stack trace for each log entry, which is then used to populate
* fields like `LogEntry__c.StackTrace__c` and `LogEntry__c.OriginLocation__c`.
* Controlled by the custom metadata record `LoggerParameter.EnableStackTraceParsing`, or `true` as the default
*/
public static final Boolean ENABLE_STACK_TRACE_PARSING {
get {
if (ENABLE_STACK_TRACE_PARSING == null) {
ENABLE_STACK_TRACE_PARSING = getBoolean('EnableStackTraceParsing', true);
}
return ENABLE_STACK_TRACE_PARSING;
}
private set;
}
/**
* @description Indicates if Nebula Logger will append its own log entries about the logging system.
* Controlled by the custom metadata record `LoggerParameter.EnableLoggerSystemMessages`, or `false` as the default
*/
public static final Boolean ENABLE_SYSTEM_MESSAGES {
get {
if (ENABLE_SYSTEM_MESSAGES == null) {
ENABLE_SYSTEM_MESSAGES = getBoolean('EnableLoggerSystemMessages', false);
}
return ENABLE_SYSTEM_MESSAGES;
}
private set;
}
/**
* @description Indicates if Nebula Logger's tagging system is enabled.
* Controlled by the custom metadata record `LoggerParameter.EnableTagging`, or `true` as the default
*/
public static final Boolean ENABLE_TAGGING {
get {
if (ENABLE_TAGGING == null) {
ENABLE_TAGGING = getBoolean('EnableTagging', true);
}
return ENABLE_TAGGING;
}
private set;
}
/**
* @description A list of JavaScript file name patterns that should be ignored when parsing stack traces.
* Any stack trace lines containing file names that match these patterns will be removed from the parsed stack trace.
* This is useful for filtering out utility or framework files from stack traces.
* Controlled by the custom metadata record `LoggerParameter.IgnoredJavaScriptOrigins`, or an empty list as the default
*/
public static final List<String> IGNORED_JAVASCRIPT_ORIGINS {
get {
if (IGNORED_JAVASCRIPT_ORIGINS == null) {
IGNORED_JAVASCRIPT_ORIGINS = getStringList('IgnoredJavaScriptOrigins', new List<String>());
}
return IGNORED_JAVASCRIPT_ORIGINS;
}
private set;
}
/**
* @description Controls the default batch size used by the batchable class `LogBatchPurger` when purging old logging data.
* Controlled by the custom metadata record `LoggerParameter.LogBatchPurgerDefaultBatchSize`, or `500` as the default
*/
public static final Integer LOG_BATCH_PURGER_DEFAULT_BATCH_SIZE {
get {
if (LOG_BATCH_PURGER_DEFAULT_BATCH_SIZE == null) {
LOG_BATCH_PURGER_DEFAULT_BATCH_SIZE = getInteger('LogBatchPurgerDefaultBatchSize', 500);
}
return LOG_BATCH_PURGER_DEFAULT_BATCH_SIZE;
}
private set;
}
/**
* @description Indicates if Nebula Logger will store scenarios in the custom object `LoggerScenario__c`,
* or in the fields `Log__c.TransactionScenarioName__c` & `LogEntry__c.EntryScenario__c`.
* Controlled by the custom metadata record `LoggerParameter.NormalizeScenarioData`, or `true` as the default
*/
public static final Boolean NORMALIZE_SCENARIO_DATA {
get {
if (NORMALIZE_SCENARIO_DATA == null) {
NORMALIZE_SCENARIO_DATA = getBoolean('NormalizeScenarioData', true);
}
return NORMALIZE_SCENARIO_DATA;
}
private set;
}
/**
* @description Indicates if Nebula Logger will store tags in the custom objects `LoggerTag__c` & `LogEntryTag__c`,
* or in the field `LogEntry__c.Tags__c`.
* Controlled by the custom metadata record `LoggerParameter.NormalizeTagData`, or `true` as the default
*/
public static final Boolean NORMALIZE_TAG_DATA {
get {
if (NORMALIZE_TAG_DATA == null) {
NORMALIZE_TAG_DATA = getBoolean('NormalizeTagData', true);
}
return NORMALIZE_TAG_DATA;
}
private set;
}
/**
* @description The name of the Platform Cache partition to use for caching (when platform cache is enabled).
* Controlled by the custom metadata record `LoggerParameter.PlatformCachePartitionName`, or `LoggerCache` as the default
*/
public static final String PLATFORM_CACHE_PARTITION_NAME {
get {
if (PLATFORM_CACHE_PARTITION_NAME == null) {
PLATFORM_CACHE_PARTITION_NAME = getString('PlatformCachePartitionName', 'LoggerCache');
}
return PLATFORM_CACHE_PARTITION_NAME;
}
private set;
}
/**
* @description Controls if Nebula Logger queries `Schema.ApexClass` data.
* When set to `false`, any `Schema.ApexClass` fields on `LogEntryEvent__e` and `Log__c` will not be populated
* Controlled by the custom metadata record `LoggerParameter.QueryApexClassData`, or `true` as the default
*/
public static final Boolean QUERY_APEX_CLASS_DATA {
get {
if (QUERY_APEX_CLASS_DATA == null) {
QUERY_APEX_CLASS_DATA = getBoolean('QueryApexClassData', true);
}
return QUERY_APEX_CLASS_DATA;
}
private set;
}
/**
* @description Controls if Nebula Logger queries `Schema.ApexTrigger` data.
* When set to `false`, any `Schema.ApexTrigger` fields on `LogEntryEvent__e` and `Log__c` will not be populated
* Controlled by the custom metadata record `LoggerParameter.QueryApexTriggerData`, or `true` as the default
*/
public static final Boolean QUERY_APEX_TRIGGER_DATA {
get {
if (QUERY_APEX_TRIGGER_DATA == null) {
QUERY_APEX_TRIGGER_DATA = getBoolean('QueryApexTriggerData', true);
}
return QUERY_APEX_TRIGGER_DATA;
}
private set;
}
/**
* @description Controls if Nebula Logger queries `Schema.AuthSession` data.
* When set to `false`, any `Schema.AuthSession` fields on `LogEntryEvent__e` and `Log__c` will not be populated
* Controlled by the custom metadata record `LoggerParameter.QueryAuthSessionData`, or `true` as the default
*/
public static final Boolean QUERY_AUTH_SESSION_DATA {
get {
if (QUERY_AUTH_SESSION_DATA == null) {
QUERY_AUTH_SESSION_DATA = getBoolean('QueryAuthSessionData', true);
}
return QUERY_AUTH_SESSION_DATA;
}
private set;
}
/**
* @description Controls if Nebula Logger queries `Schema.AuthSession` data synchronously & populated on `LogEntryEvent__e` records.
* When set to `false`, any `Schema.AuthSession` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried
* asynchronously and populated on any resulting `Log__c` records.
* Controlled by the custom metadata record `LoggerParameter.QueryAuthSessionDataSynchronously`, or `true` as the default
*/
public static final Boolean QUERY_AUTH_SESSION_DATA_SYNCHRONOUSLY {
get {
if (QUERY_AUTH_SESSION_DATA_SYNCHRONOUSLY == null) {
QUERY_AUTH_SESSION_DATA_SYNCHRONOUSLY = getBoolean('QueryAuthSessionDataSynchronously', true);
}
return QUERY_AUTH_SESSION_DATA_SYNCHRONOUSLY;
}
private set;
}
/**
* @description Controls if Nebula Logger queries `Schema.FlowDefinitionView` data.
* When set to `false`, any `Schema.FlowDefinitionView` fields on `LogEntryEvent__e` and `Log__c` will not be populated
* Controlled by the custom metadata record `LoggerParameter.QueryFlowDefinitionViewData`, or `true` as the default
*/
public static final Boolean QUERY_FLOW_DEFINITION_VIEW_DATA {
get {
if (QUERY_FLOW_DEFINITION_VIEW_DATA == null) {
QUERY_FLOW_DEFINITION_VIEW_DATA = getBoolean('QueryFlowDefinitionViewData', true);
}
return QUERY_FLOW_DEFINITION_VIEW_DATA;
}
private set;
}
/**
* @description Controls if Nebula Logger queries `Schema.OmniProcess` data.
* When set to `false`, any `Schema.OmniProcess` fields on `LogEntry__c` will not be populated
* Controlled by the custom metadata record `LoggerParameter.QueryOmniProcessData`, or `true` as the default
*/
public static final Boolean QUERY_OMNI_PROCESS_DATA {
get {
if (QUERY_OMNI_PROCESS_DATA == null) {
QUERY_OMNI_PROCESS_DATA = getBoolean('QueryOmniProcessData', true);
}
return QUERY_OMNI_PROCESS_DATA;
}
private set;
}
/**
* @description Controls if Nebula Logger queries `Schema.Network` data.
* When set to `false`, any `Schema.Network` fields on `LogEntryEvent__e` and `Log__c` will not be populated
* Controlled by the custom metadata record `LoggerParameter.QueryNetworkData`, or `true` as the default
*/
public static final Boolean QUERY_NETWORK_DATA {
get {
if (QUERY_NETWORK_DATA == null) {
QUERY_NETWORK_DATA = getBoolean('QueryNetworkData', true);
}
return QUERY_NETWORK_DATA;
}
private set;
}
/**
* @description Controls if Nebula Logger queries `Schema.Network` data is queried synchronously & populated on `LogEntryEvent__e` records.
* When set to `false`, any `Schema.Network` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried
* asynchronously and populated on any resulting `Log__c` records.
* Controlled by the custom metadata record `LoggerParameter.QueryNetworkDataSynchronously`, or `true` as the default
*/
public static final Boolean QUERY_NETWORK_DATA_SYNCHRONOUSLY {
get {
if (QUERY_NETWORK_DATA_SYNCHRONOUSLY == null) {
QUERY_NETWORK_DATA_SYNCHRONOUSLY = getBoolean('QueryNetworkDataSynchronously', true);
}
return QUERY_NETWORK_DATA_SYNCHRONOUSLY;
}
private set;
}
/**
* @description Controls if Nebula Logger queries `Schema.Organization` data.
* When set to `false`, any `Schema.Organization` fields on `LogEntryEvent__e` and `Log__c` will not be populated
* Controlled by the custom metadata record `LoggerParameter.QueryOrganizationData`, or `true` as the default
*/
public static final Boolean QUERY_ORGANIZATION_DATA {
get {
if (QUERY_ORGANIZATION_DATA == null) {
QUERY_ORGANIZATION_DATA = getBoolean('QueryOrganizationData', true);
}
return QUERY_ORGANIZATION_DATA;
}
private set;
}
/**
* @description Indicates if Nebula Logger queries `Schema.Organization` data is queried synchronously & populated on `LogEntryEvent__e` records.
* When set to `false`, any `Schema.Organization` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried
* asynchronously and populated on any resulting `Log__c` records.
* Controlled by the custom metadata record `LoggerParameter.QueryOrganizationDataSynchronously`, or `true` as the default
*/
public static final Boolean QUERY_ORGANIZATION_DATA_SYNCHRONOUSLY {
get {
if (QUERY_ORGANIZATION_DATA_SYNCHRONOUSLY == null) {
QUERY_ORGANIZATION_DATA_SYNCHRONOUSLY = getBoolean('QueryOrganizationDataSynchronously', true);
}
return QUERY_ORGANIZATION_DATA_SYNCHRONOUSLY;
}
private set;
}
/**
* @description Controls if Nebula Logger queries data for records synthetically related to a `LogEntry__c` via `LogEntry__c.RecordId__c`.
* When set to `false`, any fields on `LogEntry__c` related to `LogEntry__c.RecordId__c` not be populated
* Controlled by the custom metadata record `LoggerParameter.QueryRelatedRecordData`, or `true` as the default
*/
public static final Boolean QUERY_RELATED_RECORD_DATA {
get {
if (QUERY_RELATED_RECORD_DATA == null) {
QUERY_RELATED_RECORD_DATA = getBoolean('QueryRelatedRecordData', true);
}
return QUERY_RELATED_RECORD_DATA;
}
private set;
}
/**
* @description Controls if Nebula Logger queries `Schema.User` data.
* When set to `false`, any `Schema.User` fields on `LogEntryEvent__e` and `Log__c` will not be populated
* Controlled by the custom metadata record `LoggerParameter.QueryUserData`, or `true` as the default
*/
public static final Boolean QUERY_USER_DATA {
get {
if (QUERY_USER_DATA == null) {
QUERY_USER_DATA = getBoolean('QueryUserData', true);
}
return QUERY_USER_DATA;
}
private set;
}
/**
* @description Indicates if Nebula Logger queries `Schema.User` data is queried synchronously & populated on `LogEntryEvent__e` records.
* When set to `false`, any `Schema.User` fields on `LogEntryEvent__e` that rely on querying will not be populated - the data
* will instead be queried asynchronously and populated on any resulting `Log__c` records.
* Controlled by the custom metadata record `LoggerParameter.QueryUserDataSynchronously`, or `true` as the default
*/
public static final Boolean QUERY_USER_DATA_SYNCHRONOUSLY {
get {
if (QUERY_USER_DATA_SYNCHRONOUSLY == null) {
QUERY_USER_DATA_SYNCHRONOUSLY = getBoolean('QueryUserDataSynchronously', true);
}
return QUERY_USER_DATA_SYNCHRONOUSLY;
}
private set;
}
/**
* @description Indicates if Nebula Logger will enforce scenario-based logging to be used.
* When set to `false`, specifying a scenario is completely optional.
* When set to `true`, a scenario is required to be set before any logging can occur.
* If a logging method is called & the current scenario is null/blank, then Nebula Logger will throw a runtime exception.
* Controlled by the custom metadata record `LoggerParameter.RequireScenarioUsage`, or `false` as the default
*/
public static final Boolean REQUIRE_SCENARIO_USAGE {
get {
if (REQUIRE_SCENARIO_USAGE == null) {
// Most features in Nebula Logger are enabled (true) by default,
// but this one is intentionally set to false by default - not
// all orgs want or need to use scenario-based logging
REQUIRE_SCENARIO_USAGE = getBoolean('RequireScenarioUsage', false);
}
return REQUIRE_SCENARIO_USAGE;
}
private set;
}
/**
* @description Indicates if Nebula Logger will send an error email notification if any internal exceptions occur.
* Controlled by the custom metadata record `LoggerParameter.SendErrorEmailNotifications`, or `true` as the default
*/
public static final Boolean SEND_ERROR_EMAIL_NOTIFICATIONS {
get {
if (SEND_ERROR_EMAIL_NOTIFICATIONS == null) {
SEND_ERROR_EMAIL_NOTIFICATIONS = getBoolean('SendErrorEmailNotifications', true);
}
return SEND_ERROR_EMAIL_NOTIFICATIONS;
}
private set;
}
/**
* @description Indicates if Nebula Logger will store the transaction heap limits on `LogEntry__c`, retrieved from the class `System.Limits`.
* Controlled by the custom metadata record `LoggerParameter.StoreApexHeapSizeLimit`, or `true` as the default.
* Relies on `LoggerParameter.StoreTransactionLimits` to be true, as well.
*/
public static final Boolean STORE_HEAP_SIZE_LIMIT {
get {
if (STORE_HEAP_SIZE_LIMIT == null) {
STORE_HEAP_SIZE_LIMIT = getBoolean('StoreHeapSizeLimit', true);
}
return STORE_HEAP_SIZE_LIMIT;
}
private set;
}
/**
* @description Indicates if Nebula Logger will store the header values when logging an instance of `System.HttpRequest`.
* Controlled by the custom metadata record `LoggerParameter.StoreHttpRequestHeaderValues`, or `true` as the default.
* Regardless of how this parameter is configured, Nebula Logger will still log the specified list of header keys of any instance of
* `System.HttpRequest` that is logged - this parameter only controls if the header values are stored.
*/
public static final Boolean STORE_HTTP_REQUEST_HEADER_VALUES {
get {
if (STORE_HTTP_REQUEST_HEADER_VALUES == null) {
STORE_HTTP_REQUEST_HEADER_VALUES = getBoolean('StoreHttpRequestHeaderValues', true);
}
return STORE_HTTP_REQUEST_HEADER_VALUES;
}
private set;
}
/**
* @description Indicates if Nebula Logger will store the header values when logging an instance of `System.HttpResponse`.
* Controlled by the custom metadata record `LoggerParameter.StoreHttpResponseHeaderValues`, or `true` as the default.
* Regardless of how this parameter is configured, Nebula Logger will still log the header keys of any instance of
* `System.HttpResponse` that is logged - this parameter only controls if the header values are stored.
*/
public static final Boolean STORE_HTTP_RESPONSE_HEADER_VALUES {
get {
if (STORE_HTTP_RESPONSE_HEADER_VALUES == null) {
STORE_HTTP_RESPONSE_HEADER_VALUES = getBoolean('StoreHttpResponseHeaderValues', true);
}
return STORE_HTTP_RESPONSE_HEADER_VALUES;
}
private set;
}
/**
* @description Indicates if Nebula Logger will store the organization limits on `Log__c`, retrieved from the class `System.OrgLimits`.
* Controlled by the custom metadata record `LoggerParameter.StoreOrganizationLimits`, or `true` as the default.
*/
public static final Boolean STORE_ORGANIZATION_LIMITS {
get {
if (STORE_ORGANIZATION_LIMITS == null) {
STORE_ORGANIZATION_LIMITS = getBoolean('StoreOrganizationLimits', true);
}
return STORE_ORGANIZATION_LIMITS;
}
private set;
}
/**
* @description Indicates if Nebula Logger will store the header values when logging an instance of `System.RestRequest`.
* Controlled by the custom metadata record `LoggerParameter.StoreRestRequestHeaderValues`, or `true` as the default.
* Regardless of how this parameter is configured, Nebula Logger will still log the header keys of any instance of
* `System.RestRequest` that is logged - this parameter only controls if the header values are stored.
*/
public static final Boolean STORE_REST_REQUEST_HEADER_VALUES {
get {
if (STORE_REST_REQUEST_HEADER_VALUES == null) {
STORE_REST_REQUEST_HEADER_VALUES = getBoolean('StoreRestRequestHeaderValues', true);
}
return STORE_REST_REQUEST_HEADER_VALUES;
}
private set;
}
/**
* @description Indicates if Nebula Logger will store the header values when logging an instance of `System.RestResponse`.
* Controlled by the custom metadata record `LoggerParameter.StoreRestResponseHeaderValues`, or `true` as the default.
* Regardless of how this parameter is configured, Nebula Logger will still log the header keys of any instance of
* `System.RestResponse` that is logged - this parameter only controls if the header values are stored.
*/
public static final Boolean STORE_REST_RESPONSE_HEADER_VALUES {
get {
if (STORE_REST_RESPONSE_HEADER_VALUES == null) {
STORE_REST_RESPONSE_HEADER_VALUES = getBoolean('StoreRestResponseHeaderValues', true);
}
return STORE_REST_RESPONSE_HEADER_VALUES;
}
private set;
}
/**
* @description Indicates if Nebula Logger will store the transaction limits on `LogEntry__c`, retrieved from the class `System.Limits`.
* Controlled by the custom metadata record `LoggerParameter.StoreTransactionLimits`, or `true` as the default.
*/
public static final Boolean STORE_TRANSACTION_LIMITS {
get {
if (STORE_TRANSACTION_LIMITS == null) {
STORE_TRANSACTION_LIMITS = getBoolean('StoreTransactionLimits', true);
}
return STORE_TRANSACTION_LIMITS;
}
private set;
}
/**
* @description The merge-field syntax to use when calling System.debug().
* Controlled by the custom metadata record `LoggerParameter.SystemDebugMessageFormat`, or `{OriginLocation__c}\n{Message__c}` as the default
*/
public static final String SYSTEM_DEBUG_MESSAGE_FORMAT {
get {
if (SYSTEM_DEBUG_MESSAGE_FORMAT == null) {
SYSTEM_DEBUG_MESSAGE_FORMAT = getString('SystemDebugMessageFormat', '{OriginLocation__c}\n{Message__c}');
}
return SYSTEM_DEBUG_MESSAGE_FORMAT;
}
private set;
}
/**
* @description Indicates if `Logger.setScenario(String)` uses the first specified value (when `true`), or the last specified value (when `false`)
* Controlled by the custom metadata record `LoggerParameter.UseFirstSpecifiedScenario`, or `true` as the default
*/
public static final Boolean USE_FIRST_SCENARIO_FOR_TRANSACTION {
get {
if (USE_FIRST_SCENARIO_FOR_TRANSACTION == null) {
USE_FIRST_SCENARIO_FOR_TRANSACTION = getBoolean('UseFirstSpecifiedScenario', true);
}
return USE_FIRST_SCENARIO_FOR_TRANSACTION;
}
private set;
}
/**
* @description Indicates if Platform Cache is used to cache organization & session data in the cache partition `LoggerCache`
* Controlled by the custom metadata record `LoggerParameter.UsePlatformCache`, or `true` as the default
*/
public static final Boolean USE_PLATFORM_CACHE {
get {
if (USE_PLATFORM_CACHE == null) {
USE_PLATFORM_CACHE = getBoolean('UsePlatformCache', true);
}
return USE_PLATFORM_CACHE;
}
private set;
}
/**
* @description Indicates if Logger's tagging will use `Schema.Topic` and `Schema.TopicAssignment` for storing tags (when `true`),
* or uses Nebula Logger's custom objects `LoggerTag__c` and `LogEntryTag__c` (when `false`)
* Controlled by the custom metadata record `LoggerParameter.UseTopicsForTags`, or `false` as the default
*/
public static final Boolean USE_TOPICS_FOR_TAGS {
get {
if (USE_TOPICS_FOR_TAGS == null) {
USE_TOPICS_FOR_TAGS = getBoolean('UseTopicsForTags', false);
}
return USE_TOPICS_FOR_TAGS;
}
private set;
}
private static final Map<String, LoggerParameter__mdt> DEVELOPER_NAME_TO_RECORD {
get {
if (DEVELOPER_NAME_TO_RECORD == null) {
DEVELOPER_NAME_TO_RECORD = LoggerConfigurationSelector.getInstance().getLoggerParameters();
}
return DEVELOPER_NAME_TO_RECORD;
}
private set;
}
/**
* @description Returns the configured value of the field `Value__c` as a `Boolean`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `Boolean` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static Boolean getBoolean(String parameterDeveloperName, Boolean defaultValue) {
Boolean parameterValue = (Boolean) castParameterValue(parameterDeveloperName, Boolean.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `List<Boolean>`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `List<Boolean>` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static List<Boolean> getBooleanList(String parameterDeveloperName, List<Boolean> defaultValue) {
List<Boolean> parameterValue = (List<Boolean>) castParameterValue(parameterDeveloperName, List<Boolean>.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `Date`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `Date` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static Date getDate(String parameterDeveloperName, Date defaultValue) {
Date parameterValue = (Date) castParameterValue(parameterDeveloperName, Date.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `List<Date>`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `List<Date>` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static List<Date> getDateList(String parameterDeveloperName, List<Date> defaultValue) {
List<Date> parameterValue = (List<Date>) castParameterValue(parameterDeveloperName, List<Date>.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `Datetime`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `Datetime` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static Datetime getDatetime(String parameterDeveloperName, Datetime defaultValue) {
Datetime parameterValue = (Datetime) castParameterValue(parameterDeveloperName, Datetime.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `List<Datetime>`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `List<Datetime>` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static List<Datetime> getDatetimeList(String parameterDeveloperName, List<Datetime> defaultValue) {
List<Datetime> parameterValue = (List<Datetime>) castParameterValue(parameterDeveloperName, List<Datetime>.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `Decimal`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `Decimal` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static Decimal getDecimal(String parameterDeveloperName, Decimal defaultValue) {
Decimal parameterValue = (Decimal) castParameterValue(parameterDeveloperName, Decimal.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `List<Decimal>`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `List<Decimal>` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static List<Decimal> getDecimalList(String parameterDeveloperName, List<Decimal> defaultValue) {
List<Decimal> parameterValue = (List<Decimal>) castParameterValue(parameterDeveloperName, List<Decimal>.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `Double`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `Double` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static Double getDouble(String parameterDeveloperName, Double defaultValue) {
Double parameterValue = (Double) castParameterValue(parameterDeveloperName, Double.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `List<Double>`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `List<Double>` value configured in the matching instance of LLoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static List<Double> getDoubleList(String parameterDeveloperName, List<Double> defaultValue) {
List<Double> parameterValue = (List<Double>) castParameterValue(parameterDeveloperName, List<Double>.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `Id`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `Id` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static Id getId(String parameterDeveloperName, Id defaultValue) {
Id parameterValue = (Id) castParameterValue(parameterDeveloperName, Id.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `List<Id>`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `List<Id>` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static List<Id> getIdList(String parameterDeveloperName, List<Id> defaultValue) {
List<Id> parameterValue = (List<Id>) castParameterValue(parameterDeveloperName, List<Id>.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `Integer`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `Integer` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static Integer getInteger(String parameterDeveloperName, Integer defaultValue) {
Integer parameterValue = (Integer) castParameterValue(parameterDeveloperName, Integer.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `List<Integer>`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `List<Integer>` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static List<Integer> getIntegerList(String parameterDeveloperName, List<Integer> defaultValue) {
List<Integer> parameterValue = (List<Integer>) castParameterValue(parameterDeveloperName, List<Integer>.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `Long`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `Long` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static Long getLong(String parameterDeveloperName, Long defaultValue) {
Long parameterValue = (Long) castParameterValue(parameterDeveloperName, Long.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `List<Long>`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `List<Long>` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static List<Long> getLongList(String parameterDeveloperName, List<Long> defaultValue) {
List<Long> parameterValue = (List<Long>) castParameterValue(parameterDeveloperName, List<Long>.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `SObject`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `SObject` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static SObject getSObject(String parameterDeveloperName, SObject defaultValue) {
SObject parameterValue = (SObject) castParameterValue(parameterDeveloperName, SObject.class);
return parameterValue ?? defaultValue;
}
/**
* @description Returns the configured value of the field `Value__c` as a `List<SObject>`
* @param parameterDeveloperName The developer name of the instance of `LoggerParameter__mdt`
* @param defaultValue A default value to return instead of null
* @return The `List<SObject>` value configured in the matching instance of `LoggerParameter__mdt`
* Returns the supplied `defaultValue` when no matching parameter is found, or the parameter value is null
*/
public static List<SObject> getSObjectList(String parameterDeveloperName, List<SObject> defaultValue) {
List<SObject> parameterValue = (List<SObject>) castParameterValue(parameterDeveloperName, List<SObject>.class);
return parameterValue ?? defaultValue;
}
/**
* @description This method returns the actual parameter if it exists, or if it's empty returns the default value.
* @param parameterDeveloperName The parameter to return if it exists.
* @param defaultValue The default value to return when the parameter doesn't exist.
* @return A string that's retrieved using the parameter if it's not empty, otherwise the string is defaulted to defaultValue.
*/
public static String getString(String parameterDeveloperName, String defaultValue) {
// Since the Value__c field is already a String, this method skips using the method castParameterValue
String parameterValue = loadParameterValue(parameterDeveloperName);
return parameterValue ?? defaultValue;
}
/**
* @description This method returns the value of the parameter if it exists (cast as a list of strings), or if it's empty returns the default list.
* @param parameterDeveloperName The parameter of the list to return if it exists.
* @param defaultValue The default list to return when the parameter / value doesn't exist.
* @return A list that's retrieved using the parameter if it's not null, otherwise the default list is returned.
*/
public static List<String> getStringList(String parameterDeveloperName, List<String> defaultValue) {
List<String> parameterValue = (List<String>) castParameterValue(parameterDeveloperName, List<String>.class);
return parameterValue ?? defaultValue;
}
/**
* @description matchOnPrefix description
* @param developerNamePrefix A prefix that has been used in the `DeveloperName` for multiple `LoggerParameter__mdt` records
* @return The list of matching `LoggerParameter__mdt` records
*/
public static List<LoggerParameter__mdt> matchOnPrefix(String developerNamePrefix) {
List<LoggerParameter__mdt> matchingParameters = new List<LoggerParameter__mdt>();
for (String parameterDeveloperName : DEVELOPER_NAME_TO_RECORD.keySet()) {
if (parameterDeveloperName.startsWith(developerNamePrefix)) {
matchingParameters.add(DEVELOPER_NAME_TO_RECORD.get(parameterDeveloperName));
}
}
return matchingParameters;
}
/*
DELETEME Deprecated method, remove in a future release & instead use something like this in tests:
```
LoggerConfigurationSelector.useMocks();
LoggerConfigurationSelector.mockLoggerParameters.add(new LoggerParameter__mdt());
```
*/
@TestVisible
private static void setMock(LoggerParameter__mdt parameter) {
if (String.isBlank(parameter.DeveloperName)) {
throw new System.IllegalArgumentException('DeveloperName is required on `LoggerParameter__mdt: \n' + System.JSON.serializePretty(parameter));
}
DEVELOPER_NAME_TO_RECORD.put(parameter.DeveloperName, parameter);
}
private static Object castParameterValue(String parameterDeveloperName, System.Type dataType) {
String parameterValue = loadParameterValue(parameterDeveloperName);
if (parameterValue == null) {
return null;
} else {
return System.JSON.deserialize(parameterValue, dataType);
}
}
private static String loadParameterValue(String parameterDeveloperName) {
return DEVELOPER_NAME_TO_RECORD.get(parameterDeveloperName)?.Value__c;
}
}