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
* 4.10.0 (#320)
* New version 4.10.0
* Update CI configuration, remove husky pre-commit, and add simple-git-hooks; introduce Jest configuration and TypeScript settings
* Add prepare-publish script and update build process in package.json
* Fix path in np configuration to remove leading dot in contents
* Add pre-commit hook script to manage pre-commit tasks
* 4.10.0
* Revert version number to 4.9.3 in package.json
* 4.10.0
* Enhance pre-commit hook to check for npm availability and update package.json paths
* Refactor pre-commit hook to remove npm availability check
* 4.10.1
* Fix CJS build, add README to dist folder
* 4.10.2
* Add CI-specific launch arguments for Puppeteer
- Custom `transportFormatted` overrides now receive `logMeta` as the fourth argument; pass five parameters to also receive `settings`, otherwise adjust implementations that previously read `settings` from the fourth position.
7
+
- Deprecated runtime entry points under `src/runtime/**` and related browser mappings have been removed; use the primary `Logger` export instead of importing runtime-specific helpers.
8
+
- Logger metadata now exposes lowercase runtime identifiers (for example `node`, `browser`, `deno`, `bun`, `worker`) and normalized versions without the leading `v`; adjust consumers that compared against `Nodejs` or relied on the old format.
9
+
10
+
### Added
11
+
- Introduced universal runtime detection that recognises Node.js, browsers, web workers, Deno, and Bun, enriching metadata with runtime versions and hostnames when available.
12
+
- Documented first-class Deno and Bun usage, refreshed examples under `examples/server`, and aligned development scripts (`npm run dev-ts*`).
13
+
- Pretty transports now detect when the browser console supports CSS, rendering styled output with `%c` tokens and gracefully falling back when styling is unavailable.
14
+
- Error formatting captures chained `Error.cause` entries (up to depth five) and includes them in both pretty error blocks and JSON error objects.
15
+
16
+
### Changed
17
+
- The core logger automatically locates the first user stack frame instead of relying on hard-coded depths, producing stable file and line metadata across bundlers; manual `stackDepthLevel` overrides continue to work.
18
+
- Placeholder formatting now routes through a shared `buildPrettyMeta` utility, improving consistency for custom templates and nested style tokens.
19
+
- Masking internals normalise and cache case-insensitive keys, reducing repeated allocations and keeping behaviour consistent when toggling mask options.
- Runtime error detection now treats objects with an `Error`-suffixed name as errors, ensuring they are formatted via the error transport.
24
+
- Browser stack parsing guards against malformed frames, avoiding crashes when devtools emit unexpected stack entries.
25
+
- Logging no longer fails when `process.cwd()` throws (for example under restricted permissions); environment helpers fall back to cached working directories and hostname detection across Node, Deno, and Bun.
It's possible to add user defined tokes, by overwriting the `addPlaceholders` in the `settings.overwrite`. this callback allows to add or overwrite tokens in the `placeholderValues`.
459
-
for example, to add the token:`{{custom}}`;
461
+
You can add your own template tokens by overriding `settings.overwrite.addPlaceholders`. The callback receives the current metadata object and the placeholder map so you can add or overwrite entries.
462
+
For example, to add the token `{{custom}}`:
460
463
```javascript
461
464
constlogger=newLogger({
462
465
type:"pretty",
@@ -468,10 +471,10 @@ Following settings are available for styling:
468
471
},
469
472
});
470
473
```
471
-
this would yield in the token `{{custom}}`being replaced with`"test"`
474
+
This replaces `{{custom}}`with the string`"test"` in the rendered output.
472
475
473
476
-**Styling:**
474
-
-`stylePrettyLogs`: defines whether logs should be styled and colorized
477
+
-`stylePrettyLogs`: defines whether logs should be styled and colorized (ANSI in server runtimes, CSS in browsers that support it)
475
478
-`prettyLogStyles`: provides colors and styles for different placeholders and can also be dependent on the value (e.g. log level)
476
479
- Level 1: template placeholder (defines a style for a certain template placeholder, s. above, without brackets).
477
480
- Level 2: Either a string with one style (e.g. `white`), or an array of styles (e.g. `["bold", "white"]`), or a nested object with key being a value.
@@ -485,6 +488,8 @@ Following settings are available for styling:
485
488
`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`.
486
489
You can define the property containing this meta information with `metaProperty`, which is "_meta" by default.
487
490
491
+
`tslog` automatically determines the first caller frame outside of the library, even in bundled environments such as Vite or Next.js. If you need to override the detected frame, provide `stackDepthLevel` when constructing a `Logger`.
// overwrite the default transport for formatted (e.g. pretty) log levels. e.g. replace console with StdOut, write to file etc.
681
692
},
682
693
},
683
694
});
684
695
```
685
696
697
+
> **Note:**`transportFormatted` receives the resolved log meta as an optional fourth argument and the active settings as an optional fifth argument. Handlers that still accept only three arguments continue to work unchanged.
698
+
686
699
For `JSON` logs (no formatting happens here):
687
700
```typescript
688
701
const logger =newLogger({
@@ -701,9 +714,9 @@ For `JSON` logs (no formatting happens here):
0 commit comments