 path = require "path"
 fs = require "fs"
+http = require "http"
 
 connect = require "connect"
 colors = require "colors"
+
+logger = ->
+    for key, value of arguments
+        process.stdout.write value + " "
+    process.stdout.write "\n"
 
 directoryIndex = (directory, options) ->
     return (req, res, next) ->

        if not @options.directory.match(/^\//)
            @options.directory = path.normalize(process.cwd() + "/" + @options.directory)

        # Overwrite console if we are in quiet mode
        if @options.quiet and not @options.verbose
            console["log"] = ->

        # Create the server
        @server = connect()


    listen: ->
        # Print a startup message unless we are in quiet mode
        logger "Serving static file from directory".green, "#{@options.directory}".cyan, "on port".green, "#{@options.port}".cyan
        @server = http.createServer(@server).listen @options.port

    close: ->
        @server.close()
