 ######################
 #Functions Definition
 ######################
+
+
+
 #Format syslog TimeStamp
 formatSyslogDate = (unixtime) ->
   months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun','Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']

                            }
			    # Do something with the log ;)
#                            send_log(connection, JSON.stringify(message))
                            send_syslog(connection, formatSyslogDate(Date.now()), container, frame.content)
                        )
                    catch e
                        console.log 'could not parse packet: '.red + e.message

domain = require('domain')
fs     = require('fs')
net    = require('net')
dgram  = require('dgram')

syslog_host  = process.env.SYSLOG_HOST  || '127.0.0.1'
syslog_port  = process.env.SYSLOG_PORT  || '514'
syslog_proto = process.env.SYSLOG_PROTO || 'tcp'

# Init syslog connection depending on the protocol
initiateSyslog = (proto, host, port) ->
  if (proto == 'tcp')
    connection = net.createConnection syslog_port, syslog_host
    connection.on 'connect', () ->
    console.log((".. Opened connection to #{syslog_host}:#{syslog_port}/#{syslog_proto}").green)
    connection.on 'error', (err) ->
      console.log(("xx Error connecting to #{syslog_host}:#{syslog_port}/#{syslog_proto}").yellow)
      delay 1000, -> connection.connect syslog_port, syslog_host
    connection.on 'end', (data) ->
      console.log(('Server lost ... Retrying...').yellow)
      delay 1000, -> connection.connect syslog_port, syslog_host
    return connection
  else if (proto == 'udp')
    connection = dgram.createSocket('udp4')
    console.log((".. Socket Ready to #{syslog_host}:#{syslog_port}/#{syslog_proto}").green)
    return connection
#Initialize Outgoing log connection
connection = initiateSyslog(syslog_proto, syslog_host, syslog_port)

#Docker logging Mgmt
console.log('.. initializing docker-log-central (hit ^C to quit)')
