Ejemplo n.º 1
0
func init() {
	debugLogBuf = new(log.MutexBuffer)
	infoLogBuf = new(log.MutexBuffer)

	element.PkgLog = log.NewStdLogger(
		log.SetStdDebug(debugLogBuf, "testDebug: ", std.Lshortfile),
		log.SetStdInfo(infoLogBuf, "testInfo: ", std.Lshortfile),
	)
	element.PkgLog.SetLevel(log.StdLevelDebug)
}
Ejemplo n.º 2
0
func init() {
	debugLogBuf = new(log.MutexBuffer)
	infoLogBuf = new(log.MutexBuffer)

	model.PkgLog = log.NewStdLogger(
		log.SetStdDebug(debugLogBuf, "testDebug: ", std.Lshortfile),
		log.SetStdInfo(infoLogBuf, "testInfo: ", std.Lshortfile),
		log.SetStdDisableStackTrace(),
	)
	model.PkgLog.SetLevel(log.StdLevelDebug)
}
Ejemplo n.º 3
0
func TestStdLogger(t *testing.T) {

	var buf bytes.Buffer

	sl := log.NewStdLogger(
		log.SetStdLevel(log.StdLevelDebug),
		log.SetStdDebug(&buf, "TEST-DEBUG ", std.LstdFlags),
		log.SetStdInfo(&buf, "TEST-INFO ", std.LstdFlags),
		log.SetStdFatal(&buf, "TEST-FATAL ", std.LstdFlags),
	)
	sl.SetLevel(log.StdLevelInfo)
	assert.False(t, sl.IsDebug())
	assert.True(t, sl.IsInfo())

	sl.Debug("my Debug", "float", 3.14152)
	sl.Debug("my Debug2", 2.14152)
	sl.Info("InfoTEST")

	logs := buf.String()

	assert.Contains(t, logs, "InfoTEST")
	assert.NotContains(t, logs, "Debug2")

	buf.Reset()
	sl.SetLevel(log.StdLevelDebug)
	assert.True(t, sl.IsDebug())
	assert.True(t, sl.IsInfo())
	sl.Debug("my Debug", "float", 3.14152)
	sl.Debug("my Debug2", 2.14152)
	sl.Info("InfoTEST")

	logs = buf.String()

	assert.Contains(t, logs, "InfoTEST")
	assert.Contains(t, logs, "Debug2")

}
func initStore() {
	store.PkgLog = log.NewStdLogger(
		log.SetStdDebug(&testDebugLogBuf, "testErr: ", std.Lshortfile),
	)
	store.PkgLog.SetLevel(log.StdLevelDebug)

	testStoreService = store.MustNewService(
		scope.Option{
			Website: scope.MockID(1), // bound to website ID 1 = Europe
		},
		store.MustNewStorage(
			// Storage gets usually loaded from the database tables containing
			// website, group and store. For the sake of this example the storage
			// is hard coded.
			store.SetStorageWebsites(
				&store.TableWebsite{WebsiteID: 0, Code: dbr.NewNullString("admin"), Name: dbr.NewNullString("Admin"), SortOrder: 0, DefaultGroupID: 0, IsDefault: dbr.NewNullBool(false)},
				&store.TableWebsite{WebsiteID: 1, Code: dbr.NewNullString("euro"), Name: dbr.NewNullString("Europe"), SortOrder: 0, DefaultGroupID: 1, IsDefault: dbr.NewNullBool(true)},
				&store.TableWebsite{WebsiteID: 2, Code: dbr.NewNullString("oz"), Name: dbr.NewNullString("OZ"), SortOrder: 20, DefaultGroupID: 3, IsDefault: dbr.NewNullBool(false)},
			),
			store.SetStorageGroups(
				&store.TableGroup{GroupID: 3, WebsiteID: 2, Name: "Australia", RootCategoryID: 2, DefaultStoreID: 5},
				&store.TableGroup{GroupID: 1, WebsiteID: 1, Name: "DACH Group", RootCategoryID: 2, DefaultStoreID: 2},
				&store.TableGroup{GroupID: 0, WebsiteID: 0, Name: "Default", RootCategoryID: 0, DefaultStoreID: 0},
				&store.TableGroup{GroupID: 2, WebsiteID: 1, Name: "UK Group", RootCategoryID: 2, DefaultStoreID: 4},
			),
			store.SetStorageStores(
				&store.TableStore{StoreID: 0, Code: dbr.NewNullString("admin"), WebsiteID: 0, GroupID: 0, Name: "Admin", SortOrder: 0, IsActive: true},
				&store.TableStore{StoreID: 5, Code: dbr.NewNullString("au"), WebsiteID: 2, GroupID: 3, Name: "Australia", SortOrder: 10, IsActive: true},
				&store.TableStore{StoreID: 1, Code: dbr.NewNullString("de"), WebsiteID: 1, GroupID: 1, Name: "Germany", SortOrder: 10, IsActive: true},
				&store.TableStore{StoreID: 4, Code: dbr.NewNullString("uk"), WebsiteID: 1, GroupID: 2, Name: "UK", SortOrder: 10, IsActive: true},
				&store.TableStore{StoreID: 2, Code: dbr.NewNullString("at"), WebsiteID: 1, GroupID: 1, Name: "Österreich", SortOrder: 20, IsActive: true},
				&store.TableStore{StoreID: 6, Code: dbr.NewNullString("nz"), WebsiteID: 2, GroupID: 3, Name: "Kiwi", SortOrder: 30, IsActive: true},
				&store.TableStore{IsActive: false, StoreID: 3, Code: dbr.NewNullString("ch"), WebsiteID: 1, GroupID: 1, Name: "Schweiz", SortOrder: 30},
			),
		),
	)
}
Ejemplo n.º 5
0
func init() {
	store.PkgLog = log.NewStdLogger(
		log.SetStdDebug(&errLogBuf, "testErr: ", std.Lshortfile),
	)
	store.PkgLog.SetLevel(log.StdLevelDebug)
}