đź“‘ Zero-dependency, fast logging library for Node, Browser and Workers
BREAKING CHANGE
Log functions no longer require a message string in the first argument, this means
reporters that used to tap into extra
for the spread arguments you will now
find this in the messages
array.
- const reporter: Reporter = ({ name, level, message, extra, ...rest })
+ const reporter: Reporter = ({ name, level, messages, ...rest })
..
- console.log({ message, extra });
+ const message = messages.shift();
+ console.log({ message, extra: messages });
enable
by default, see a4d95bccd4db33f2cbca91ef2034113eb319f6c1In the past we enbaled anyting in the DEBUG
localStorage key,
this lead to some undesired behaviours when working with sandboxed
iframes.
Now we will let the you control this completely, as from what I can see the majority of folk I see, use it anyway.
Still makes sense to run this for Node applications, which is left un touched.
If you want the existing behaviour, just attached this before you start logging.
import { enable } from 'diary';
enable(localStorage.DEBUG || 'a^');
Full Changelog: https://github.com/maraisr/diary/compare/v0.3.1...v0.4.0
Features
Full Changelog: https://github.com/maraisr/diary/compare/0.3.0...v0.3.1
Features
BREAKING CHANGES
enable
api. (61486c8f0aea97dc37226ffb75204a0cb45f7c66)Chores
Full Changelog: https://github.com/maraisr/diary/compare/0.2.2...0.3.0
Bug fixes
diary/index
as the resolution path its diary/node/index
which for obvious reasons doesn't have types. Now we just force the root to diary/index.d.ts
— 70475fd348f0a9485d26241257c71460590ec82aFeatures
deno
publishFeatures
diary
now supports being used in a Cloudflare Worker — enabled via an Environment Variable named DEBUG
to behave the same as though it was a node or browser runtime.
Build
diary
is now built in 3 flavors and relies on bundles to import the correct one.
Features
compare
util to help with log level comparing.import { compare } from 'diary/utils';
// when `a` is _less-than_ `b` then -1
compare('warn', 'error');
// when `a` is _more-than_ `b` then 1
compare('fatal', 'error');
// when `a` is the _same_ as`b` then 0
compare('fatal', 'fatal');
Features
import { defaultReporter } from 'diary';
Chores
Breaking
setLevel
method—all events will now log irrespective of their level.
onEmit
callback to squash these.before
/after
. As it turns out, with the new onEmit
api on diary. One can create the same effect—with much less overhead.Features
enable
method to control the allow list programmatically.onEmit
argument to the diary
constructor. Allows you to output the log entries to other places, than console.log
.diary/json
sub-module that allows formatting the messages as json!Chores