Skip to content

Commit 9f798a6

Browse files
committed
Add LICENSE
1 parent 5174fc1 commit 9f798a6

File tree

3 files changed

+49
-28
lines changed

3 files changed

+49
-28
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
👨‍👧‍👦 **Sub logger with inheritance**<br>
3131
🙊 **Mask/hide secrets and keys**<br>
3232
📦 **ESM with tree shaking support**<br>
33-
✍️ **well documented and tested**<br>
33+
✍️ **Well documented and tested**<br>
3434

3535
## Example
3636

@@ -132,8 +132,8 @@ logger.fatal(new Error("I am a pretty Error with a stacktrace."));
132132
- **Native source maps lookup:** Shows exact position also in TypeScript code (compile-to-JS), one click to IDE position
133133
- **Pretty Error:** Errors and stack traces printed in a structured way and fully accessible through _JSON_ (e.g. external Log services)
134134
- **ES Modules:** import syntax with ([tree-shaking](https://webpack.js.org/guides/tree-shaking/))
135-
- **Object/JSON highlighting:** Nicely prints out an objects
136-
- **Sub Logger with inheritance:** Powerful sub loggers with settings inheritance, also at runtime
135+
- **Object/JSON highlighting:** Nicely prints out objects
136+
- **Sub Logger with inheritance:** Powerful sub-loggers with settings inheritance, also at runtime
137137
- **Secrets masking:** Prevent passwords and secrets from sneaking into log files by masking them
138138
- **Short paths:** Paths are relative to the root of the application folder
139139
- **Prefixes:** Prefix log messages and bequeath prefixes to child loggers
@@ -142,13 +142,13 @@ logger.fatal(new Error("I am a pretty Error with a stacktrace."));
142142

143143
### <a name="life_cycle"></a>Lifecycle of a log message
144144

145-
Every incoming log message runs through a number of steps before being displayed or handed over to a "transport". Every steps can be overwritten and adjusted.
145+
Every incoming log message runs through a number of steps before being displayed or handed over to a "transport". Every step can be overwritten and adjusted.
146146

147147
![tslog pretty output](https://raw.githubusercontent.com/fullstack-build/tslog/master/docs/assets/tslog_lifesycle.png "tslog: life cycle of a log message")
148148

149149
- **log message** Log message comes in through the `BaseLogger.log()` method
150150
- **mask** If masking is configured, log message gets recursively masked
151-
- **toLogObj** Log message gets transformed into a log object: A default typed log object can be passed to constructor as a second parameter and will be cloned and enriched with the incoming log parameters. Error properties will be handled accordingly. If there is only one log property, and it's an object, both objects (cloned default `logObj` as well as the log property object will be merged.) Are there more than one, they will be pu into properties called "0", "1", ... and so on. Alternatively, log message properties can be put into a property with a name configured with the `argumentsArrayName` setting.
151+
- **toLogObj** Log message gets transformed into a log object: A default typed log object can be passed to constructor as a second parameter and will be cloned and enriched with the incoming log parameters. Error properties will be handled accordingly. If there is only one log property, and it's an object, both objects (cloned default `logObj` as well as the log property object will be merged.) If there are more than one, they will be put into properties called "0", "1", ... and so on. Alternatively, log message properties can be put into a property with a name configured with the `argumentsArrayName` setting.
152152
- **addMetaToLogObj** Additional meta information, like the source code position of the log will be gathered and added to the `_meta` property or any other one configured with the setting `metaProperty`.
153153
- **format** In case of "pretty" configuration, a log object will be formatted based on the templates configured in settings. Meta will be formatted by the method `_prettyFormatLogObjMeta` and the actual log payload will be formatted by `prettyFormatLogObj`. Both steps can be overwritten with the settings `formatMeta` and `formatMeta`.
154154
- **transport** Last step is to "transport" a log message to every attached transport from the setting `attachedTransports`. Last step is the actual transport, either JSON (`transportJSON`), formatted (`transportFormatted`) or omitted, if its set to "hidden". Both default transports can also be overwritten by the corresponding setting.
@@ -178,7 +178,7 @@ In addition to the default log level, custom log level can be defined in the sam
178178
`log` method expects the following parameters:
179179
- logLevelId - Log level ID e.g. 0
180180
- logLevelName - Log level name e.g. silly
181-
- args - Multiple log attributes that should be logged out.
181+
- args - Multiple log attributes that should be logged.
182182

183183
> **Tip:** Also the generic logging method (log()) returns a _JSON_ representation of the log message (`ILogObject`).
184184
@@ -192,7 +192,7 @@ export class CustomLogger<LogObj> extends BaseLogger<LogObj> {
192192

193193
/**
194194
* Logs a _CUSTOM_ message.
195-
* @param args - Multiple log attributes that should be logged out.
195+
* @param args - Multiple log attributes that should be logged.
196196
*/
197197
public custom(...args: unknown[]): LogObj & ILogObjMeta {
198198
return super.log(8, "CUSTOM", ...args);
@@ -202,7 +202,7 @@ export class CustomLogger<LogObj> extends BaseLogger<LogObj> {
202202
```
203203

204204
### Settings
205-
`tslog` is highly customizable and pretty much every aspect can bei either configured or overwritten.
205+
`tslog` is highly customizable and pretty much every aspect can be either configured or overwritten.
206206
A `settings` object is the first parameter passed to the `tslog` constructor:
207207

208208
```typescript
@@ -270,7 +270,7 @@ Enables you to overwrite the looks of a formatted _"pretty"_ log message by prov
270270
Following settings are available for styling:
271271

272272
- **Templates:**
273-
- `prettyLogTemplate`: template string for logs message. Possible placeholder:
273+
- `prettyLogTemplate`: template string for log messages. Possible placeholders:
274274
- `{{yyyy}}`: year
275275
- `{{mm}}`: month
276276
- `{{dd}}`: day
@@ -282,13 +282,13 @@ Following settings are available for styling:
282282
- `{{logLevelName}}`: name of the log level
283283
- `{{fullFilePath}}`: a full path starting from `/` root
284284
- `{{filePathWithLine}}`: a full path below the project path with line number
285-
- `prettyErrorTemplate`: template string for error message. Possible placeholder:
285+
- `prettyErrorTemplate`: template string for error message. Possible placeholders:
286286
- `{{errorName}}`: name of the error
287287
- `{{errorMessage}}`: error message
288288
- `{{errorStack}}`: Placeholder for all stack lines defined by `prettyErrorStackTemplate`
289-
- `prettyErrorStackTemplate`: template string for error stack trace lines. Possible placeholder:
289+
- `prettyErrorStackTemplate`: template string for error stack trace lines. Possible placeholders:
290290
- `{{fileName}}`: name of the file
291-
- `{{filePathWithLine}}`: a full path below the project path with line number
291+
- `{{filePathWithLine}}`: a full path below the project path with a line number
292292
- `{{method}}`: _optional_ name of the invoking method
293293
- `prettyInspectOptions`: <a href="https://nodejs.org/api/util.html#utilinspectobject-options" target="_blank">Available options</a>
294294

@@ -302,7 +302,7 @@ Following settings are available for styling:
302302

303303
#### Log meta information
304304
`tslog` collects meta information for every log, like runtime, code position etc. The meta information collected depends on the runtime (browser or Node.js) and is accessible through the `LogObj`.
305-
You can define the property containing this meta information with `metaProperty`, which is "_meta" per default.
305+
You can define the property containing this meta information with `metaProperty`, which is "_meta" by default.
306306

307307
#### Pretty templates and styles (color settings)
308308

@@ -340,7 +340,7 @@ There are multiple ways of masking secrets, before they get exposed:
340340

341341
- `maskPlaceholder`: Placeholder to replaced masked secrets with, Default: `[***]`
342342
- `maskValuesOfKeys`: Array of keys to replace the values with the placeholder (`maskPlaceholder`). Default: `["password"]`
343-
- `maskValuesOfKeysCaseInsensitive`: Should the keys be matched case insensitive (e.g. "password" would replace "password" as well as "Password", and "PASSWORD"). Default: `false`
343+
- `maskValuesOfKeysCaseInsensitive`: Should the keys be matched case-insensitive (e.g. "password" would replace "password" as well as "Password", and "PASSWORD"). Default: `false`
344344
- `maskValuesRegEx`: For even more flexibility, you can also replace strings and object values with a RegEx.
345345

346346
#### Prefixing logs

docs/README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
👨‍👧‍👦 **Sub logger with inheritance**<br>
3131
🙊 **Mask/hide secrets and keys**<br>
3232
📦 **ESM with tree shaking support**<br>
33-
✍️ **well documented and tested**<br>
33+
✍️ **Well documented and tested**<br>
3434

3535
## Example
3636

@@ -132,8 +132,8 @@ logger.fatal(new Error("I am a pretty Error with a stacktrace."));
132132
- **Native source maps lookup:** Shows exact position also in TypeScript code (compile-to-JS), one click to IDE position
133133
- **Pretty Error:** Errors and stack traces printed in a structured way and fully accessible through _JSON_ (e.g. external Log services)
134134
- **ES Modules:** import syntax with ([tree-shaking](https://webpack.js.org/guides/tree-shaking/))
135-
- **Object/JSON highlighting:** Nicely prints out an objects
136-
- **Sub Logger with inheritance:** Powerful sub loggers with settings inheritance, also at runtime
135+
- **Object/JSON highlighting:** Nicely prints out objects
136+
- **Sub Logger with inheritance:** Powerful sub-loggers with settings inheritance, also at runtime
137137
- **Secrets masking:** Prevent passwords and secrets from sneaking into log files by masking them
138138
- **Short paths:** Paths are relative to the root of the application folder
139139
- **Prefixes:** Prefix log messages and bequeath prefixes to child loggers
@@ -142,13 +142,13 @@ logger.fatal(new Error("I am a pretty Error with a stacktrace."));
142142

143143
### <a name="life_cycle"></a>Lifecycle of a log message
144144

145-
Every incoming log message runs through a number of steps before being displayed or handed over to a "transport". Every steps can be overwritten and adjusted.
145+
Every incoming log message runs through a number of steps before being displayed or handed over to a "transport". Every step can be overwritten and adjusted.
146146

147147
![tslog pretty output](https://raw.githubusercontent.com/fullstack-build/tslog/master/docs/assets/tslog_lifesycle.png "tslog: life cycle of a log message")
148148

149149
- **log message** Log message comes in through the `BaseLogger.log()` method
150150
- **mask** If masking is configured, log message gets recursively masked
151-
- **toLogObj** Log message gets transformed into a log object: A default typed log object can be passed to constructor as a second parameter and will be cloned and enriched with the incoming log parameters. Error properties will be handled accordingly. If there is only one log property, and it's an object, both objects (cloned default `logObj` as well as the log property object will be merged.) Are there more than one, they will be pu into properties called "0", "1", ... and so on. Alternatively, log message properties can be put into a property with a name configured with the `argumentsArrayName` setting.
151+
- **toLogObj** Log message gets transformed into a log object: A default typed log object can be passed to constructor as a second parameter and will be cloned and enriched with the incoming log parameters. Error properties will be handled accordingly. If there is only one log property, and it's an object, both objects (cloned default `logObj` as well as the log property object will be merged.) If there are more than one, they will be put into properties called "0", "1", ... and so on. Alternatively, log message properties can be put into a property with a name configured with the `argumentsArrayName` setting.
152152
- **addMetaToLogObj** Additional meta information, like the source code position of the log will be gathered and added to the `_meta` property or any other one configured with the setting `metaProperty`.
153153
- **format** In case of "pretty" configuration, a log object will be formatted based on the templates configured in settings. Meta will be formatted by the method `_prettyFormatLogObjMeta` and the actual log payload will be formatted by `prettyFormatLogObj`. Both steps can be overwritten with the settings `formatMeta` and `formatMeta`.
154154
- **transport** Last step is to "transport" a log message to every attached transport from the setting `attachedTransports`. Last step is the actual transport, either JSON (`transportJSON`), formatted (`transportFormatted`) or omitted, if its set to "hidden". Both default transports can also be overwritten by the corresponding setting.
@@ -178,7 +178,7 @@ In addition to the default log level, custom log level can be defined in the sam
178178
`log` method expects the following parameters:
179179
- logLevelId - Log level ID e.g. 0
180180
- logLevelName - Log level name e.g. silly
181-
- args - Multiple log attributes that should be logged out.
181+
- args - Multiple log attributes that should be logged.
182182

183183
> **Tip:** Also the generic logging method (log()) returns a _JSON_ representation of the log message (`ILogObject`).
184184
@@ -192,7 +192,7 @@ export class CustomLogger<LogObj> extends BaseLogger<LogObj> {
192192

193193
/**
194194
* Logs a _CUSTOM_ message.
195-
* @param args - Multiple log attributes that should be logged out.
195+
* @param args - Multiple log attributes that should be logged.
196196
*/
197197
public custom(...args: unknown[]): LogObj & ILogObjMeta {
198198
return super.log(8, "CUSTOM", ...args);
@@ -202,7 +202,7 @@ export class CustomLogger<LogObj> extends BaseLogger<LogObj> {
202202
```
203203

204204
### Settings
205-
`tslog` is highly customizable and pretty much every aspect can bei either configured or overwritten.
205+
`tslog` is highly customizable and pretty much every aspect can be either configured or overwritten.
206206
A `settings` object is the first parameter passed to the `tslog` constructor:
207207

208208
```typescript
@@ -270,7 +270,7 @@ Enables you to overwrite the looks of a formatted _"pretty"_ log message by prov
270270
Following settings are available for styling:
271271

272272
- **Templates:**
273-
- `prettyLogTemplate`: template string for logs message. Possible placeholder:
273+
- `prettyLogTemplate`: template string for log messages. Possible placeholders:
274274
- `{{yyyy}}`: year
275275
- `{{mm}}`: month
276276
- `{{dd}}`: day
@@ -282,13 +282,13 @@ Following settings are available for styling:
282282
- `{{logLevelName}}`: name of the log level
283283
- `{{fullFilePath}}`: a full path starting from `/` root
284284
- `{{filePathWithLine}}`: a full path below the project path with line number
285-
- `prettyErrorTemplate`: template string for error message. Possible placeholder:
285+
- `prettyErrorTemplate`: template string for error message. Possible placeholders:
286286
- `{{errorName}}`: name of the error
287287
- `{{errorMessage}}`: error message
288288
- `{{errorStack}}`: Placeholder for all stack lines defined by `prettyErrorStackTemplate`
289-
- `prettyErrorStackTemplate`: template string for error stack trace lines. Possible placeholder:
289+
- `prettyErrorStackTemplate`: template string for error stack trace lines. Possible placeholders:
290290
- `{{fileName}}`: name of the file
291-
- `{{filePathWithLine}}`: a full path below the project path with line number
291+
- `{{filePathWithLine}}`: a full path below the project path with a line number
292292
- `{{method}}`: _optional_ name of the invoking method
293293
- `prettyInspectOptions`: <a href="https://nodejs.org/api/util.html#utilinspectobject-options" target="_blank">Available options</a>
294294

@@ -302,7 +302,7 @@ Following settings are available for styling:
302302

303303
#### Log meta information
304304
`tslog` collects meta information for every log, like runtime, code position etc. The meta information collected depends on the runtime (browser or Node.js) and is accessible through the `LogObj`.
305-
You can define the property containing this meta information with `metaProperty`, which is "_meta" per default.
305+
You can define the property containing this meta information with `metaProperty`, which is "_meta" by default.
306306

307307
#### Pretty templates and styles (color settings)
308308

@@ -340,7 +340,7 @@ There are multiple ways of masking secrets, before they get exposed:
340340

341341
- `maskPlaceholder`: Placeholder to replaced masked secrets with, Default: `[***]`
342342
- `maskValuesOfKeys`: Array of keys to replace the values with the placeholder (`maskPlaceholder`). Default: `["password"]`
343-
- `maskValuesOfKeysCaseInsensitive`: Should the keys be matched case insensitive (e.g. "password" would replace "password" as well as "Password", and "PASSWORD"). Default: `false`
343+
- `maskValuesOfKeysCaseInsensitive`: Should the keys be matched case-insensitive (e.g. "password" would replace "password" as well as "Password", and "PASSWORD"). Default: `false`
344344
- `maskValuesRegEx`: For even more flexibility, you can also replace strings and object values with a RegEx.
345345

346346
#### Prefixing logs

0 commit comments

Comments
 (0)