mentie 0.3.26 → 0.4.1
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/logging.js +29 -4
- package/package.json +2 -2
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 = [ 'debug', '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: 'debug'
|
|
124
|
+
* 🎯 Goal: log extremely verbose messages that you probably don't want to see
|
|
125
|
+
*/
|
|
126
|
+
log.debug = function( ...messages ) {
|
|
127
|
+
|
|
128
|
+
// Check if the loglevel matches this call
|
|
129
|
+
const levels = [ 'debug' ]
|
|
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', 'debug' ]
|
|
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', 'debug' ]
|
|
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', 'debug' ]
|
|
182
207
|
if( !should_log( levels ) ) return
|
|
183
208
|
|
|
184
209
|
// Annotate the provided messages
|
package/package.json
CHANGED