示例#1
0
文件: logger.go 项目: tempbottle/xweb
func main() {
	f, err := os.Create("server.log")
	if err != nil {
		println(err.Error())
		return
	}
	logger := log.New(f, "", log.Ldate|log.Ltime)

	xweb.AddAction(&MainAction{})
	xweb.SetLogger(logger)
	xweb.Run("0.0.0.0:9999")
}
示例#2
0
文件: server.go 项目: tempbottle/xweb
func NewServer(args ...string) *Server {
	name := ""
	if len(args) == 1 {
		name = args[0]
	} else {
		name = fmt.Sprintf("Server%d", ServerNumber)
		ServerNumber++
	}
	s := &Server{
		Config:       Config,
		Env:          map[string]interface{}{},
		Apps:         map[string]*App{},
		AppsNamePath: map[string]string{},
		Name:         name,
	}
	Servers[s.Name] = s

	s.SetLogger(log.New(os.Stdout, "", log.Ldefault()))

	app := NewApp("/", "root")
	s.AddApp(app)
	return s
}