Skip to content

Commit 35f99f0

Browse files
authored
Merge pull request #91 from navikt/logger-readme
Logger readme and definition file for applicaiton-monitoring
2 parents 05fd8de + 1cd8870 commit 35f99f0

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

sfdx-project.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,10 @@
4848
]
4949
},
5050
{
51-
"versionName": "ver 0.1",
52-
"versionNumber": "0.1.0.NEXT",
5351
"path": "src/application-monitoring",
54-
"default": false,
5552
"package": "application-monitoring",
56-
"versionDescription": "Rammeverk for logging"
53+
"versionNumber": "0.1.0.NEXT",
54+
"definitionFile": "config/scratch-org-def.json"
5755
}
5856
],
5957
"packageAliases": {

src/application-monitoring/README.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,23 @@
22

33
## Application Log
44

5-
Logger rammeverk som publiserer logger til Application_Log\_\_c
5+
This package contains an application logging framework that can be used for logging various events either på utilizing the _LoggerUtility_ apex class, or by generating _Application_Log\_\_c_ records via process builder, flow, workflow etc. The logger has four log levels: (Error, Warning, Info, Critical). It is highly recommended to also pass a _CRM_ApplicationDomain.Domain_ parameter, which defines which area of the application is both creating the log entry and is responsible for follow up. Calling the respective logger methods can be done as shown:
66

7-
Datamodellen ligger i pakken [platform-data-model](src/platform-data-model/README.md)
7+
```Apex
8+
LoggerUtility logger = new LoggerUtility();
9+
logger.Info('Message', SObjectRef, domain);
10+
logger.Warning('Message', SObjectRef, domain);
11+
logger.Error('Message', SObjectRef, domain);
12+
logger.Critical('Message', SObjectRef, domain);
13+
14+
logger.Exception(ex, domain) //Used for logging catched exceptions
15+
logger.publish();
16+
```
17+
18+
The logger framework automatically adds the stacktrace, source function and source class to the log record when creating a log entry. To allow for application logging while also rolling back a transaction the framework includes also an _Application_Event\_\_e_ platform event counterpart that can be published even when rolling back transactions, _the standard publish() will generate a platform event_. Each log entry generates an unique UUID at runtime that can be handy for i.e. callouts requiring unique callout references in the callout chain. This examples returns the UUID of the last logged event:
19+
`logger.peek().UUID__c`
20+
21+
The data model is available in [platform-data-model](src/platform-data-model/README.md)
822

923
| | |
1024
| ------- | --- |
@@ -13,29 +27,16 @@ Datamodellen ligger i pakken [platform-data-model](src/platform-data-model/READM
1327
| Flow ||
1428
| Trigger ||
1529

16-
## Hvordan ta i bruk
30+
````
1731
18-
Husk å angi teamet som er ansvarlig for funksjonaliteten som logges i LoggerUtility.
32+
## Dependencies
1933
20-
```java
21-
private LoggerUtility logger = new LoggerUtility(
22-
CRM_ApplicationDomain.Domain.PLATFORCE,
23-
'LoginFlow'
24-
);
25-
26-
logger.errorAndPublish('Error message');
27-
logger.warningAndPublish('Warning message');
28-
logger.infoAndPublish('Info message');
29-
```
30-
31-
## Avhengigheter
32-
33-
- [platform-datamodel](src/platform-data-model/feature-flag-custom-metadata) - datamodell
34+
- [platform-datamodel](src/platform-data-model/feature-flag-custom-metadata) - data model
3435
3536
```mermaid
3637
---
37-
title: Pakkeavhengigheter
38+
title: Package dependencies
3839
---
3940
graph TD
4041
application-monitoring --> platform-datamodel;
41-
```
42+
````

0 commit comments

Comments
 (0)