- Most functions now live directly in the dbx package - dbxp and dbxm are now ONLY the few functions that cannot be shared
31 lines
757 B
Go
31 lines
757 B
Go
package dbxshared
|
|
|
|
type Logger interface {
|
|
InitLogger()
|
|
}
|
|
|
|
type dialectString interface {
|
|
String() string
|
|
}
|
|
|
|
var loggerRegistry = make(map[string]Logger)
|
|
|
|
// RegisterLogger allows dialect-specific loggers to be registered.
|
|
func RegisterLogger(dialect dialectString, logger Logger) {
|
|
dialectStr := dialect.String()
|
|
if _, exists := loggerRegistry[dialectStr]; exists {
|
|
panic("Logger for dialect already registered: " + dialectStr)
|
|
}
|
|
loggerRegistry[dialectStr] = logger
|
|
}
|
|
|
|
// InitLogger initializes the logger for a specific dialect.
|
|
func InitLogger(dialect dialectString) {
|
|
dialectStr := dialect.String()
|
|
logger, exists := loggerRegistry[dialectStr]
|
|
if !exists {
|
|
panic("No logger registered for dialect: " + dialectStr)
|
|
}
|
|
logger.InitLogger()
|
|
}
|