@odg/log 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +59 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -34,6 +34,9 @@
34
34
  - [📰 Usage](#-usage)
35
35
  - [🙈 Exception](#-exception)
36
36
  - [🔐 Implementation](#-implementation)
37
+ - [🍰 Free Sample](#-free-sample)
38
+ - [🔉 Class Aware Log](#-class-aware-log)
39
+ - [👀 Create Logger Class](#-create-logger-class)
37
40
  - [💻 Prepare to develop](#-prepare-to-develop)
38
41
  - [📍 Start Project](#-start-project)
39
42
  - [📨 Build and Run](#-build-and-run)
@@ -88,6 +91,62 @@ InvalidArgumentException dispatch if send invalid arguments
88
91
  - AbstractLogger Abstract class to logger implements only log function
89
92
  - NullLogger Generic logger without action
90
93
 
94
+ ### 🍰 Free Sample
95
+
96
+ #### 🔉 Class Aware Log
97
+
98
+ If you class dependencies LoggerInstance use interface `LoggerAwareInterface`
99
+
100
+ > if you prefer you can depend on the log class in your constructor
101
+
102
+ ```typescript
103
+ import { LoggerAwareInterface, LoggerInterface } from "@odg/log";
104
+
105
+ export class LoggerAwareExample implements LoggerAwareInterface {
106
+
107
+ private logger?: LoggerInterface;
108
+
109
+ public setLogger(logger: LoggerInterface): void {
110
+ this.logger = logger;
111
+ }
112
+
113
+ public runExampleClass(): void {
114
+ try {
115
+ // Anything code
116
+ } catch (error) {
117
+ this.logger?.debug(error);
118
+ }
119
+ }
120
+
121
+ }
122
+ ```
123
+
124
+ #### 👀 Create Logger Class
125
+
126
+ ```typescript
127
+ /**
128
+ * This Example Logger using console.log
129
+ *
130
+ * @author Dragons Gamers <https://github.com/ODGodinho>
131
+ */
132
+ export class ConsoleLogger extends AbstractLogger {
133
+
134
+ /**
135
+ * Logs with an arbitrary level.
136
+ *
137
+ * @param {LogLevel} level Log level
138
+ * @param {unknown} message Message Log
139
+ * @param {TContext} context Context Message replace
140
+ *
141
+ * @returns {Promise<void>}
142
+ */
143
+ public async log(level: LogLevel, message: unknown, context?: TContext): Promise<void> {
144
+ return console.log(`Level: ${level} >> ${String(message)}`, context);
145
+ }
146
+
147
+ }
148
+ ```
149
+
91
150
  ## 💻 Prepare To Develop
92
151
 
93
152
  Copy `.env.example` to `.env` and add the values according to your needs.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odg/log",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Interface logs types",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",