@@ -151,6 +151,48 @@ func ConfigureWithOutputs(defaultLoggerCfg Config, outputs ...zapcore.Core) erro
151151	return  nil 
152152}
153153
154+ // ConfigureWithCore configures the global logger to use the passed in 
155+ // core.  It is assumed that an output has already been defined with 
156+ // the core and a new one should not be created.  The loggerCfg is 
157+ // only used to set selectors and level.  This is useful if a part of 
158+ // your code uses logp but the log output is already handled.  Normal 
159+ // use cases should use Configure or ConfigureWithOutput. 
160+ func  ConfigureWithCore (loggerCfg  Config , core  zapcore.Core ) error  {
161+ 	var  (
162+ 		sink   zapcore.Core 
163+ 		level  zap.AtomicLevel 
164+ 	)
165+ 
166+ 	level  =  zap .NewAtomicLevelAt (loggerCfg .Level .ZapLevel ())
167+ 	sink  =  wrappedCore (core )
168+ 
169+ 	// Enabled selectors when debug is enabled. 
170+ 	selectors  :=  make (map [string ]struct {}, len (loggerCfg .Selectors ))
171+ 	if  loggerCfg .Level .Enabled (DebugLevel ) &&  len (loggerCfg .Selectors ) >  0  {
172+ 		for  _ , sel  :=  range  loggerCfg .Selectors  {
173+ 			selectors [strings .TrimSpace (sel )] =  struct {}{}
174+ 		}
175+ 
176+ 		// Default to all enabled if no selectors are specified. 
177+ 		if  len (selectors ) ==  0  {
178+ 			selectors ["*" ] =  struct {}{}
179+ 		}
180+ 
181+ 		sink  =  selectiveWrapper (sink , selectors )
182+ 	}
183+ 
184+ 	root  :=  zap .New (sink , makeOptions (loggerCfg )... )
185+ 	storeLogger (& coreLogger {
186+ 		selectors :    selectors ,
187+ 		rootLogger :   root ,
188+ 		globalLogger : root .WithOptions (zap .AddCallerSkip (1 )),
189+ 		logger :       newLogger (root , "" ),
190+ 		level :        level ,
191+ 		observedLogs : nil ,
192+ 	})
193+ 	return  nil 
194+ }
195+ 
154196// ConfigureWithTypedOutput configures the global logger to use typed outputs. 
155197// 
156198// If a log entry matches the defined key/value, this entry is logged using the 
0 commit comments