 
   # Compile browser scripts
   gulp.task 'compile:' + dist + ':scripts:browser', ['clean:build:' + dist], ->
-    logHeader = [
-      "var log = require.main.require('./utils/logger').debugLogger(__filename);"
-      "var logError = require.main.require('./utils/logger').errorLogger(__filename, false);"
-      "var logFatal = require.main.require('./utils/logger').errorLogger(__filename, true);"
+    loggerHeader = [
+      "if (__filename.indexOf('logger.js') == -1)"
+      "{"
+      "var __LOGGER = require.main.require('./utils/logger');"
+      "var log = __LOGGER.debugLogger(__filename);"
+      "var logError = __LOGGER.errorLogger(__filename, false);"
+      "var logFatal = __LOGGER.errorLogger(__filename, true);"
+      "__LOGGER = undefined;"
+      "}"
     ].join ''
 
     gulp.src './src/scripts/browser/**/*.js'

        ]
      .pipe gif args.dev, sourcemaps.write {sourceRoot: 'src/scripts/browser'}
      .pipe gif args.dev, header "require('source-map-support').install();"
      .pipe header logHeader
      .pipe plumber.stop()
      .pipe gulp.dest dir + '/scripts/browser'

  # Compile renderer scripts
  gulp.task 'compile:' + dist + ':scripts:renderer', ['clean:build:' + dist], ->
    logHeader = [
      "var log = require.main.require('./logger').debugLogger(__filename);"
      "var logError = require.main.require('./logger').errorLogger(__filename, false);"
      "var logFatal = require.main.require('./logger').errorLogger(__filename, true);"
    ].join ''

    gulp.src './src/scripts/renderer/**/*.js'

          'default-import-checker'
        ]
      .pipe gif args.dev, sourcemaps.write {sourceRoot: 'src/scripts/renderer'}
      .pipe header loggerHeader
      .pipe plumber.stop()
      .pipe gulp.dest dir + '/scripts/renderer'
      .pipe livereload()
