mentie 0.3.24 → 0.4.0
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.
- package/modules/environment.js +1 -1
- package/modules/logging.js +29 -4
- package/package.json +1 -1
package/modules/environment.js
CHANGED
|
@@ -63,7 +63,7 @@ env.dev = () => env.node_dev() || env.web_dev()
|
|
|
63
63
|
* Retrieves the log level set via URL parameters in a web environment.
|
|
64
64
|
* @returns {string|null} The log level from URL parameters, or null if not set.
|
|
65
65
|
*/
|
|
66
|
-
env.web_loglevel = () => env.is_web() && new URLSearchParams( location?.search ).get( 'loglevel' ) || new URLSearchParams( location?.search ).get( 'log_level' )
|
|
66
|
+
env.web_loglevel = () => env.is_web() && ( new URLSearchParams( location?.search ).get( 'loglevel' ) || new URLSearchParams( location?.search ).get( 'log_level' ) )
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* Retrieves the log level set via environment variables in a Node.js environment.
|
package/modules/logging.js
CHANGED
|
@@ -8,7 +8,7 @@ const should_log = levels => {
|
|
|
8
8
|
const loglevel = env.loglevel()
|
|
9
9
|
|
|
10
10
|
// Check if the loglevel matches this call
|
|
11
|
-
const valid_levels = [ 'info', 'warn', 'error' ]
|
|
11
|
+
const valid_levels = [ 'chatter', 'info', 'warn', 'error' ]
|
|
12
12
|
|
|
13
13
|
// Check if the loglevel is valid
|
|
14
14
|
if( !valid_levels.includes( loglevel ) ) console.warn( `Invalid log level: ${ loglevel }` )
|
|
@@ -118,6 +118,31 @@ export function log( ...messages ) {
|
|
|
118
118
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Extremely verbose logs that you should probably never use.
|
|
123
|
+
* Only logs if ?loglevel= or LOG_LEVEL= is set to: 'chatter'
|
|
124
|
+
* 🎯 Goal: log extremely verbose messages that you probably don't want to see
|
|
125
|
+
*/
|
|
126
|
+
log.chatter = function( ...messages ) {
|
|
127
|
+
|
|
128
|
+
// Check if the loglevel matches this call
|
|
129
|
+
const levels = [ 'chatter' ]
|
|
130
|
+
|
|
131
|
+
// Log the messages if the loglevel matches
|
|
132
|
+
if( should_log( levels ) ) {
|
|
133
|
+
|
|
134
|
+
// Annotate the provided messages
|
|
135
|
+
messages = annotate_messages( messages )
|
|
136
|
+
|
|
137
|
+
// Log the messages
|
|
138
|
+
console.log( '💬 ', ...messages )
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
121
146
|
/**
|
|
122
147
|
* Logs the provided info messages to the console.
|
|
123
148
|
* Only logs in firebase emulator or if ?loglevel= or LOG_LEVEL= is set to: 'info'
|
|
@@ -128,7 +153,7 @@ export function log( ...messages ) {
|
|
|
128
153
|
log.info = function( ...messages ) {
|
|
129
154
|
|
|
130
155
|
// Check if the loglevel matches this call
|
|
131
|
-
const levels = [ 'info' ]
|
|
156
|
+
const levels = [ 'info', 'chatter' ]
|
|
132
157
|
|
|
133
158
|
// Log the messages if the loglevel matches
|
|
134
159
|
if( env.is_emulator() || should_log( levels ) ) {
|
|
@@ -153,7 +178,7 @@ log.info = function( ...messages ) {
|
|
|
153
178
|
log.warn = function( ...messages ) {
|
|
154
179
|
|
|
155
180
|
// Check if the loglevel matches this call
|
|
156
|
-
const levels = [ 'warn', 'info' ]
|
|
181
|
+
const levels = [ 'warn', 'info', 'chatter' ]
|
|
157
182
|
|
|
158
183
|
// Log the messages if the loglevel matches
|
|
159
184
|
if( dev || should_log( levels ) ) {
|
|
@@ -178,7 +203,7 @@ log.warn = function( ...messages ) {
|
|
|
178
203
|
log.error = function( ...messages ) {
|
|
179
204
|
|
|
180
205
|
// Check if the loglevel matches this call
|
|
181
|
-
const levels = [ 'error', 'warn', 'info' ]
|
|
206
|
+
const levels = [ 'error', 'warn', 'info', 'chatter' ]
|
|
182
207
|
if( !should_log( levels ) ) return
|
|
183
208
|
|
|
184
209
|
// Annotate the provided messages
|