OpenSource » Database Migrator » Legacy Migrator
Clone URL:  

Migrator (No commit message)

Changeset 3d92bf72278f

Parent e1a84c03ec02

by danielpupek

Changes to one file · Browse files at 3d92bf72278f Showing diff from parent e1a84c03ec02 Diff from another changeset...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
 
28
29
30
31
32
33
34
35
36
 
37
38
39
40
41
42
43
44
45
46
 
47
48
49
50
51
52
53
 
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
27
28
29
30
31
32
33
34
35
 
 
36
37
38
 
39
40
41
42
43
44
 
45
46
47
48
49
 
 
 
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
 #region License  //The contents of this file are subject to the Mozilla Public License  //Version 1.1 (the "License"); you may not use this file except in  //compliance with the License. You may obtain a copy of the License at  //http://www.mozilla.org/MPL/  //Software distributed under the License is distributed on an "AS IS"  //basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the  //License for the specific language governing rights and limitations  //under the License.  #endregion  using System;    namespace Migrator.Loggers  {   /// <summary>   /// Console logger for the migration mediator   /// </summary>   public class ConsoleLogger : ILogger   {   private int _widthFirstColumn = 5;   private bool _trace = false;   private log4net.ILog _logger = log4net.LogManager.GetLogger("Migrator");     public ConsoleLogger(bool trace)   {   _trace = trace; - (_logger.Logger as log4net.Repository.Hierarchy.Logger).AddAppender(new log4net.Appender.ConsoleAppender()); + var layout = new log4net.Layout.PatternLayout("%message"); + (_logger.Logger as log4net.Repository.Hierarchy.Logger).AddAppender(new log4net.Appender.ConsoleAppender(layout));   (_logger.Logger as log4net.Repository.Hierarchy.Logger).Level = log4net.Core.Level.All;       }     public void Started(int currentVersion, int finalVersion)   { - - Console.WriteLine("Migrating from Current Version: {0} to version {1}", currentVersion, finalVersion); +   _logger.InfoFormat("Migrating from Current Version: {0} to version {1}", currentVersion, finalVersion);   -   }     public void MigrateUp(int version, string migrationName)   {   if (this._trace)   { - Console.WriteLine("{0} {1}", version.ToString().PadLeft(_widthFirstColumn), migrationName); +   _logger.InfoFormat("{0} {1}", version.ToString().PadLeft(_widthFirstColumn), migrationName);   }     else - { - - Console.Write("..{0}", version.ToString()); + {   _logger.InfoFormat("..{0}", version.ToString());   }   }     public void MigrateDown(int version, string migrationName)   {   MigrateUp(version, migrationName);   }     public void Skipping(int version)   {   Console.WriteLine("{0} {1}", version.ToString().PadLeft(_widthFirstColumn), "<Migration not found>");   }     public void RollingBack(int originalVersion)   {   Console.WriteLine("Rolling back to migration {0}", originalVersion);   }     public void Exception(int version, string migrationName, Exception ex)   {   Console.WriteLine("{0} Error in migration {1} : {2}", "".PadLeft(_widthFirstColumn), version, ex.Message);   this.TraceException(ex);   }     public void Exception(string format, Exception ex, params object[] args)   {   Console.Write("{0} ", "".PadLeft(_widthFirstColumn));   Console.WriteLine(format, args);   this.TraceException(ex);   }     public void Finished(int originalVersion, int currentVersion)   {   if (_trace)   Console.WriteLine("Finished migrating to version {0}", currentVersion);   else   Console.Write(".. Done.");   }     public void Log(string format, params object[] args)   {   Console.Write("{0} ", "".PadLeft(_widthFirstColumn));   Console.WriteLine(format, args);   }     public void Warn(string format, params object[] args)   {   Console.Write("{0} Warning! : ", "".PadLeft(_widthFirstColumn));   Console.WriteLine(format, args);   }     public void Trace(string format, params object[] args)   {   if (_trace)   {   Log(format, args);   }   }     private void TraceException(Exception ex)   {   if (_trace)   {   Console.WriteLine("========= Error detail =========");   Console.WriteLine(ex);   Console.WriteLine(ex.StackTrace);   Exception iex = ex.InnerException;   while (ex.InnerException != null)   {   Console.WriteLine("Caused by: {0}", ex.InnerException);   Console.WriteLine(ex.InnerException.StackTrace);   iex = iex.InnerException;   }   Console.WriteLine("======================================");   }   }     }  }