 CHANNEL_KEY_FOR_XML_MAPPING = 'expectedStock'
 CHANNEL_REF_NAME = 'supplyChannel'
 CHANNEL_ROLES = ['InventorySupply', 'OrderExport', 'OrderImport']
+LOG_PREFIX = "[SphereStockImport] "
 
 class StockImport
 
   _log: (msg) ->
     if @client?
       client._logger.info msg
-    console.log "[SphereStockImport] #{msg}"
+    console.log "#{LOG_PREFIX}#{msg}"
 
   constructor: (options) ->
     if options?

        if entry[CHANNEL_REF_NAME]?
          msg.body.CHANNEL_ID = entry[CHANNEL_REF_NAME].id
        ElasticIo.returnSuccess msg, next
      Q 'elastic.io messages sent.'
    else
      @_initMatcher().then =>
        @_createOrUpdate stocks

            roles: channelRolesForCreation
          rest.POST '/channels', channel, (error, response, body) ->
            if error?
              deferred.reject "#{LOG_PREFIX}Error on creating channel: #{error}"
            else if response.statusCode is 201
              deferred.resolve body
            else
              humanReadable = JSON.stringify body, null, 2
              deferred.reject "#{LOG_PREFIX}Problem on creating channel: #{humanReadable}"

    deferred.promise

