Created
June 8, 2012 17:53
-
-
Save bierbaum/2897222 to your computer and use it in GitHub Desktop.
ostrich examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Admin Stuff | |
object Admin { | |
val handlers = new MutableHashMap[String, CgiRequestHandler] | |
def register(config: AdminServiceConfig) { | |
config.extraHandlers = handlers | |
} | |
object Hi extends CgiRequestHandler { | |
def handle(exchange: HttpExchange, path: List[String], parameters: List[(String, String)]) { | |
val writer = new StringWriter | |
writer.write("Hello") | |
val bytes = writer.toString.getBytes | |
exchange.getResponseHeaders.set("Content-Type", "text/plain") | |
exchange.sendResponseHeaders(200, bytes.length) | |
val output: OutputStream = exchange.getResponseBody() | |
output.write(bytes) | |
output.flush() | |
output.close() | |
exchange.close() | |
} | |
} | |
handlers.put("/hi", Hi) | |
} | |
// call Admin.register(adminConfig) from your config file or where you bootstrap Admin. | |
// ------------------------------------------------ // | |
// Logging | |
val logBase = "/var/log/myproject/" | |
val logLevel = Level.INFO | |
loggers = | |
new LoggerConfig { | |
// Root logger | |
level = Level.WARNING | |
handlers = new FileHandlerConfig { | |
filename = logBase + "myproject.log" | |
roll = Policy.SigHup | |
} | |
} :: new LoggerConfig { | |
node = "other-topic" | |
level = logLevel | |
useParents = false | |
handlers = new FileHandlerConfig { | |
filename = logBase + "other.log" | |
roll = Policy.SigHup | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment