@@ -41,12 +41,6 @@ let serve = require('./serve'); // eslint-disable-line
41
41
const pattern_assembler = new pa ( ) ;
42
42
const lineage_hunter = new lh ( ) ;
43
43
44
- //register our log events
45
- plutils . log . on ( 'error' , msg => console . log ( msg ) ) ;
46
- plutils . log . on ( 'debug' , msg => console . log ( msg ) ) ;
47
- plutils . log . on ( 'warning' , msg => console . log ( msg ) ) ;
48
- plutils . log . on ( 'info' , msg => console . log ( msg ) ) ;
49
-
50
44
const patternEngines = require ( './pattern_engines' ) ;
51
45
const EventEmitter = require ( 'events' ) . EventEmitter ;
52
46
@@ -64,6 +58,9 @@ class PatternLab {
64
58
// Make ye olde event emitter
65
59
this . events = new PatternLabEventEmitter ( ) ;
66
60
61
+ //register our log events
62
+ this . registerLogger ( config . debug ) ;
63
+
67
64
// Make a place for the pattern graph to sit
68
65
this . graph = null ;
69
66
@@ -247,6 +244,39 @@ class PatternLab {
247
244
//write the compiled template to the public patterns directory
248
245
outputFiles . forEach ( outFile => fs . outputFileSync ( outFile . path , outFile . content ) ) ;
249
246
}
247
+
248
+
249
+
250
+ /**
251
+ * Binds console logging to different levels
252
+ *
253
+ * @param {string } logLevel
254
+ * @memberof PatternLab
255
+ */
256
+ registerLogger ( logLevel ) {
257
+
258
+ // handle the legacy value, which is boolean
259
+ if ( typeof logLevel === 'boolean' ) {
260
+ if ( logLevel ) {
261
+ plutils . log . on ( 'debug' , msg => console . log ( msg ) ) ;
262
+ }
263
+ plutils . log . on ( 'info' , msg => console . log ( msg ) ) ;
264
+ plutils . log . on ( 'warning' , msg => console . log ( msg ) ) ;
265
+ plutils . log . on ( 'error' , msg => console . log ( msg ) ) ;
266
+ } else {
267
+ if ( logLevel === 'quiet' ) { return ; }
268
+ switch ( logLevel ) {
269
+ case 'debug' :
270
+ plutils . log . on ( 'debug' , msg => console . log ( msg ) ) ;
271
+ case 'info' :
272
+ plutils . log . on ( 'info' , msg => console . log ( msg ) ) ;
273
+ case 'warning' :
274
+ plutils . log . on ( 'warning' , msg => console . log ( msg ) ) ;
275
+ case 'error' :
276
+ plutils . log . on ( 'error' , msg => console . log ( msg ) ) ;
277
+ }
278
+ }
279
+ }
250
280
}
251
281
252
282
//bootstrap update notifier
@@ -320,6 +350,7 @@ function processAllPatternsRecursive(patterns_dir, patternlab) {
320
350
}
321
351
322
352
function checkConfiguration ( patternlab ) {
353
+
323
354
//default the output suffixes if not present
324
355
const outputFileSuffixes = {
325
356
rendered : '.rendered' ,
0 commit comments