You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple logger built as class decorator, amplify like.
8
8
9
-
## Important
9
+
## Quick Start
10
10
11
-
**Experimental decorators** are used for this package implementation and since experimental it has some bugs like unsafe typing.
11
+
### Usage
12
+
13
+
Due to the experimental decorators feature, there are some limitations.
14
+
Starting from the preferred syntax `@Logger()`
15
+
16
+
In TypeScript you need to simply enable `experimentalDecorators: true` in your `tsconfig.json`, to be able to use the preferred syntax.
17
+
18
+
In JavaScript you need to use external libraries like [@babel/plugin-proposal-decorators](https://www.npmjs.com/package/@babel/plugin-proposal-decorators) to use the preferred syntax.
19
+
20
+
Anyway since a decorator is just a function, you can use it by importing the `loggerDecorator` method.
As previously said, **experimental decorators** are used for this package implementation and since experimental it has some bugs like `unsafe typing`.
12
52
TypeScript compiler complains when it finds out a property used inside a class that calls a decorator cause it cannot infer it, so as a temporary workaround simply declare an interface
13
53
14
54
```ts
@@ -20,4 +60,10 @@ class Example {
20
60
this.logger.debug() // THIS IS VALID
21
61
}
22
62
}
23
-
```
63
+
```
64
+
65
+
## Contributing
66
+
67
+
This has been developed as a personal project, in order to be able to have an amplify-like logger as a package, without needing to install the whole amplify lib for just logging features.
68
+
69
+
But feel free to contribute by forking this project and opening a PR once done.
0 commit comments