@@ -5,8 +5,7 @@ var read = require('./read')
55var update = require ( './update' )
66var notify = require ( './notify' )
77var watch = require ( './watch' )
8-
9- module . exports = {
8+ var config = module . exports = {
109 use : [
1110 require ( '../settings' ) ,
1211 ] ,
@@ -22,23 +21,26 @@ module.exports = {
2221 } ,
2322
2423 get : function ( result , name ) {
25- var ulog = this
26- if ( ! ulog . config ) {
27- ulog . config = { } ;
28- var newCfg = read ( ulog )
29- var changed = update ( ulog . config , newCfg )
30- if ( changed . length ) notify ( ulog , changed )
31- watch ( ulog )
24+ if ( ! this . config ) {
25+ config . update ( this )
3226 }
3327 if ( ! result ) {
34- var settings = grab ( ulog , 'settings' , { } )
28+ var settings = grab ( this , 'settings' , { } )
3529 name = settings [ name ] && settings [ name ] . config || name
36- result = ulog . config [ name ]
30+ result = this . config [ name ]
3731 }
3832 return result
3933 } ,
4034
35+ update : function ( ulog ) {
36+ ulog . config = ulog . config || { }
37+ var newCfg = read ( ulog )
38+ var changed = update ( ulog . config , newCfg )
39+ if ( changed . length ) notify ( ulog , changed )
40+ watch ( ulog )
41+ } ,
42+
4143 set : function ( name ) {
42- if ( name === 'log_config' ) this . config = read ( this )
44+ if ( name === 'log_config' ) config . update ( this )
4345 }
4446}
0 commit comments