PageRenderTime 38ms CodeModel.GetById 34ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Rhino.Etl.Cmd/RhinoEtlRunner.cs

http://github.com/ayende/rhino-etl
C# | 45 lines | 41 code | 4 blank | 0 comment | 1 complexity | fedab561c03cfa6ef0b00bb032decd44 MD5 | raw file
 1namespace Rhino.Etl.Cmd
 2{
 3    using System;
 4    using System.IO;
 5    using Common.Logging.Configuration;
 6    using Common.Logging.Log4Net;
 7    using Core;
 8    using log4net;
 9    using log4net.Config;
10
11    public class RhinoEtlRunner : MarshalByRefObject
12    {
13        private readonly ILog log = LogManager.GetLogger(typeof (RhinoEtlRunner));
14
15        public static void SetupLogging(bool verbose)
16        {
17            Common.Logging.LogManager.Adapter = new Log4NetLoggerFactoryAdapter(new NameValueCollection());
18
19            string configurationName = "Rhino.Etl.Cmd.standard.log4net.config";
20            if (verbose)
21                configurationName = "Rhino.Etl.Cmd.verbose.log4net.config";
22            using (Stream stream = typeof(RhinoEtlSetup).Assembly.GetManifestResourceStream(configurationName))
23                XmlConfigurator.Configure(stream);
24        }
25
26        public void Start(Type type, bool verboseLogging)
27        {
28            try
29            {
30                SetupLogging(verboseLogging);
31                EtlProcess process = (EtlProcess)Activator.CreateInstance(type);
32                process.Execute();
33                foreach (Exception error in process.GetAllErrors())
34                {
35                    log.Debug(error);
36                    log.Error(error.Message);
37                }
38            }
39            catch (Exception e)
40            {
41                log.Error(e);
42            }
43        }
44    }
45}