33<img align="right" width="92" height="92" title="Nano Stores logo"
44 src="https://nanostores.github.io/nanostores/logo.svg">
55
6- Logger of lifecycles and changes for ** [ Nano Stores] ** ,
6+ Logger of lifecycles, changes and actions for ** [ Nano Stores] ** ,
77a tiny state manager with many atomic tree-shakable stores.
88
99* ** Clean.** All messages are stacked in compact, collapsible nested groups.
@@ -46,7 +46,7 @@ let destroy = logger({
4646#### Disable specific types of logs
4747
4848Using ` messages ` option you can disable
49- ** mount** , ** unmount** or ** change ** log messages.
49+ ** mount** , ** unmount** , ** change ** or ** action ** log messages.
5050
5151``` js
5252import { logger } from ' @nanostores/logger'
@@ -61,12 +61,30 @@ let destroy = logger({ $users }, {
6161})
6262```
6363
64+ #### Disable logs of actions with a specific name
65+
66+ Using the ` ignoreActions ` option, you can specify the names of actions
67+ that will not be logged.
68+
69+ ``` js
70+ import { logger } from ' @nanostores/logger'
71+
72+ import { $users } from ' ./stores/index.js'
73+
74+ let destroy = logger ({ $users }, {
75+ ignoreActions: [
76+ ' Change Username' ,
77+ ' Fetch User Profile'
78+ ]
79+ })
80+ ```
81+
6482### Custom messages
6583
6684You can create custom log messages and collapsible nested groups of messages
6785with your own name and badge color or with any predefined types.
6886
69- Available types: ` arguments ` , ` build ` , ` change ` , ` error ` , ` mount ` ,
87+ Available types: ` action ` , ` arguments ` , ` build ` , ` change ` , ` error ` , ` mount ` ,
7088` new ` , ` old ` , ` unmount ` , ` value ` .
7189
7290``` js
@@ -121,12 +139,29 @@ let destroy = buildLogger($profile, 'Profile', {
121139 console .log (` ${ storeName} was unmounted` )
122140 },
123141
124- change : ({ storeName, changed, newValue, oldValue, valueMessage }) => {
142+ change : ({ storeName, actionName, changed, newValue, oldValue, valueMessage }) => {
125143 let message = ` ${ storeName} was changed`
126144 if (changed) message += ` in the ${ changed} key`
127145 if (oldValue) message += ` from ${ oldValue} `
128146 message += ` to ${ newValue} `
147+ if (actionName) message += ` by action ${ actionName} `
129148 console .log (message, valueMessage)
149+ },
150+
151+ action: {
152+ start : ({ actionName, args }) => {
153+ let message = ` ${ actionName} was started`
154+ if (args .length ) message += ' with arguments'
155+ console .log (message, args)
156+ },
157+
158+ error : ({ actionName, error }) => {
159+ console .log (` ${ actionName} was failed` , error)
160+ },
161+
162+ end : ({ actionName }) => {
163+ console .log (` ${ actionName} was ended` )
164+ }
130165 }
131166})
132167```
0 commit comments