Skip to content

Commit 3fe0c9c

Browse files
committed
After-merge logging related changes
- files summaries update - other minor changes
1 parent 0afc1c1 commit 3fe0c9c

File tree

15 files changed

+133
-100
lines changed

15 files changed

+133
-100
lines changed

Extensions/Xtensive.Orm.Logging.NLog/Log.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2013-2020 Xtensive LLC.
1+
// Copyright (C) 2013-2022 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Dmitri Maximov
@@ -17,22 +17,6 @@ public class Log : BaseLog
1717
{
1818
private readonly Logger target;
1919

20-
private static NLogLevel ConvertLevel(LogLevel level)
21-
{
22-
switch (level) {
23-
case LogLevel.Debug:
24-
return NLogLevel.Debug;
25-
case LogLevel.Error:
26-
return NLogLevel.Error;
27-
case LogLevel.FatalError:
28-
return NLogLevel.Fatal;
29-
case LogLevel.Warning:
30-
return NLogLevel.Warn;
31-
default:
32-
return NLogLevel.Info;
33-
}
34-
}
35-
3620
/// <inheritdoc/>
3721
public override bool IsLogged(LogLevel level)
3822
{
@@ -48,6 +32,22 @@ public override void Write(in LogEventInfo info)
4832
target.Log(ConvertLevel(info.Level), info.FormattedMessage);
4933
}
5034

35+
private static NLogLevel ConvertLevel(in LogLevel level)
36+
{
37+
switch (level) {
38+
case LogLevel.Debug:
39+
return NLogLevel.Debug;
40+
case LogLevel.Error:
41+
return NLogLevel.Error;
42+
case LogLevel.FatalError:
43+
return NLogLevel.Fatal;
44+
case LogLevel.Warning:
45+
return NLogLevel.Warn;
46+
default:
47+
return NLogLevel.Info;
48+
}
49+
}
50+
5151
/// <summary>
5252
/// Creates instance of <see cref="Log"/> class.
5353
/// </summary>
Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2014-2020 Xtensive LLC.
1+
// Copyright (C) 2014-2022 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Alexey Kulakov
@@ -16,25 +16,7 @@ namespace Xtensive.Orm.Logging.log4net
1616
/// </summary>
1717
public class Log : BaseLog
1818
{
19-
private log4netLog target;
20-
21-
private Level ConvertLevel(LogLevel level)
22-
{
23-
switch (level) {
24-
case LogLevel.Debug:
25-
return Level.Debug;
26-
case LogLevel.Info:
27-
return Level.Info;
28-
case LogLevel.Warning:
29-
return Level.Warn;
30-
case LogLevel.Error:
31-
return Level.Error;
32-
case LogLevel.FatalError:
33-
return Level.Fatal;
34-
default:
35-
return Level.Info;
36-
}
37-
}
19+
private readonly log4netLog target;
3820

3921
/// <inheritdoc />
4022
public override bool IsLogged(LogLevel level)
@@ -48,6 +30,24 @@ public override void Write(in LogEventInfo info)
4830
target.Logger.Log(target.Logger.GetType(), ConvertLevel(info.Level), info.FormattedMessage, info.Exception);
4931
}
5032

33+
private Level ConvertLevel(in LogLevel level)
34+
{
35+
switch (level) {
36+
case LogLevel.Debug:
37+
return Level.Debug;
38+
case LogLevel.Info:
39+
return Level.Info;
40+
case LogLevel.Warning:
41+
return Level.Warn;
42+
case LogLevel.Error:
43+
return Level.Error;
44+
case LogLevel.FatalError:
45+
return Level.Fatal;
46+
default:
47+
return Level.Info;
48+
}
49+
}
50+
5151
/// <summary>
5252
/// Creates instance of <see cref="Log"/> class.
5353
/// </summary>
@@ -57,6 +57,7 @@ public override void Write(in LogEventInfo info)
5757
public Log(Assembly repositoryAssembly, string name)
5858
{
5959
target = log4netLogManager.GetLogger(repositoryAssembly, name);
60+
6061
}
6162
}
6263
}

Orm/Xtensive.Orm.Tests.Core/DotNetFramework/NewTupleLogicTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2009-2022 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Alex Yakunin
55
// Created: 2009.09.02
66

Orm/Xtensive.Orm.Tests.Core/DotNetFramework/ThreadingTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (C) 2008-2021 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Alex Yakunin
55
// Created: 2008.05.27
66

Orm/Xtensive.Orm/InternalLogs.tt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ namespace Xtensive
2020
return instance.IsLogged(type);
2121
}
2222

23-
public static IDisposable DebugRegion(string format, params object[] args)
23+
public static IndentManager.IndentScope DebugRegion(string messageId, params object[] args)
2424
{
2525
return instance.DebugRegion(format, args);
2626
}
2727

28-
public static IDisposable InfoRegion(string format, params object[] args)
28+
public static IndentManager.IndentScope InfoRegion(string messageId, params object[] args)
2929
{
3030
return instance.InfoRegion(format, args);
3131
}
3232

3333
<# foreach (var level in logLevels) { #>
34-
public static void <#= level #>(string format, params object[] args)
34+
public static void <#= level #>(string messageId, params object[] args)
3535
{
3636
instance.<#= level #>(format, args);
3737
}
3838

39-
public static Exception <#= level #>(Exception exception, string format, params object[] args)
39+
public static Exception <#= level #>(Exception exception, string messageId, params object[] args)
4040
{
4141
instance.<#= level #>(format, args, exception);
4242
return exception;

Orm/Xtensive.Orm/Modelling/Comparison/Upgrader.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,18 @@ public IReadOnlyList<NodeAction> GetUpgradeSequence(Difference difference, HintS
160160
.ForEach(validationHints.Add);
161161
var diff = comparer.Compare(CurrentModel, TargetModel, validationHints);
162162
if (diff != null) {
163-
CoreLog.InfoRegion(nameof(Strings.LogAutomaticUpgradeSequenceValidation));
164-
CoreLog.Info(nameof(Strings.LogValidationFailed));
165-
CoreLog.Info(nameof(Strings.LogItemFormat), Strings.Difference);
166-
CoreLog.Info("{0}", diff);
167-
CoreLog.Info(Strings.LogItemFormat + "\r\n{1}", Strings.UpgradeSequence,
168-
new ActionSequence() { actions });
169-
CoreLog.Info(nameof(Strings.LogItemFormat), Strings.ExpectedTargetModel);
170-
TargetModel.Dump();
171-
CoreLog.Info(nameof(Strings.LogItemFormat), Strings.ActualTargetModel);
172-
CurrentModel.Dump();
173-
throw new InvalidOperationException(Strings.ExUpgradeSequenceValidationFailure);
163+
using (CoreLog.InfoRegion(nameof(Strings.LogAutomaticUpgradeSequenceValidation))) {
164+
CoreLog.Info(nameof(Strings.LogValidationFailed));
165+
CoreLog.Info(nameof(Strings.LogItemFormat), Strings.Difference);
166+
CoreLog.Info(diff.ToString());
167+
CoreLog.Info(Strings.LogItemFormat + "\r\n{1}", Strings.UpgradeSequence,
168+
new ActionSequence() { actions });
169+
CoreLog.Info(nameof(Strings.LogItemFormat), Strings.ExpectedTargetModel);
170+
TargetModel.Dump();
171+
CoreLog.Info(nameof(Strings.LogItemFormat), Strings.ActualTargetModel);
172+
CurrentModel.Dump();
173+
throw new InvalidOperationException(Strings.ExUpgradeSequenceValidationFailure);
174+
}
174175
}
175176

176177
return new ReadOnlyCollection<NodeAction>(actions.Actions.ToArray());

Orm/Xtensive.Orm/Orm/Logging/BaseLog.cs

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2013 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2013-2022 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Alexey Kulakov
55
// Created: 2013.10.11
66

@@ -29,7 +29,10 @@ public abstract class BaseLog
2929
/// <summary>
3030
/// Creates region. Within the region, all messages are indented.
3131
/// </summary>
32-
/// <param name="messageId">Identifier of the message in resources that should be written at the begging and at the end of the region or message itself.</param>
32+
/// <param name="messageId">
33+
/// Identifier of the message in resources that should be written at the begging
34+
/// and at the end of the region or message itself.
35+
/// </param>
3336
/// <param name="parameters">Values of parameters in <paramref name="messageId"/> (resource string or message itself).</param>
3437
/// <returns><see cref="IDisposable"/> object. Region will closed by disposing of this object.</returns>
3538
public IndentManager.IndentScope DebugRegion(string messageId, params object[] parameters)
@@ -47,8 +50,13 @@ public IndentManager.IndentScope DebugRegion(string messageId, params object[] p
4750
/// <summary>
4851
/// Creates region. Within the region, all messages are indented.
4952
/// </summary>
50-
/// <param name="messageId">Identifier of the message in resources that should be written at the begging and at the end of the region or message itself.</param>
51-
/// <param name="parameters">Values of parameters in <paramref name="messageId"/> (resource string or message itself).</param>
53+
/// <param name="messageId">
54+
/// Identifier of the message in resources that should be written at the begging
55+
/// and at the end of the region or message itself.
56+
/// </param>
57+
/// <param name="parameters">
58+
/// Values of parameters in <paramref name="messageId"/> (resource string or message itself).
59+
/// </param>
5260
/// <returns><see cref="IDisposable"/> object. Region will closed by disposing of this object.</returns>
5361
public IndentManager.IndentScope InfoRegion(string messageId, params object[] parameters)
5462
{
@@ -64,44 +72,63 @@ public IndentManager.IndentScope InfoRegion(string messageId, params object[] pa
6472
/// <summary>
6573
/// Writes debug message.
6674
/// </summary>
67-
/// <param name="messageId">Identifier of the message in resources that should be written at the begging and at the end of the region or message itself.</param>
68-
/// <param name="parameters">Values of parameters in <paramref name="messageId"/> (resource string or message itself).</param>
75+
/// <param name="messageId">
76+
/// Identifier of message in resources that should be written to log or message itself.
77+
/// </param>
78+
/// <param name="parameters">
79+
/// Values of parameters in <paramref name="messageId"/> (resource string or message itself).
80+
/// </param>
6981
/// <param name="exception">Exception, which must be written.</param>
7082
public virtual void Debug(string messageId, object[] parameters = null, Exception exception = null) =>
7183
Write(LogLevel.Debug, messageId, parameters, exception);
7284

7385
/// <summary>
7486
/// Writes information message.
7587
/// </summary>
76-
/// <param name="messageId">Identifier of message in resources that should be written to log or message itself.</param>
77-
/// <param name="parameters">Values of parameters in <paramref name="messageId"/> (resource string or message itself).</param>
88+
/// <param name="messageId">
89+
/// Identifier of message in resources that should be written to log or message itself.</param>
90+
/// <param name="parameters">
91+
/// Values of parameters in <paramref name="messageId"/> (resource string or message itself).
92+
/// </param>
7893
/// <param name="exception">Exception, which must be written.</param>
7994
public virtual void Info(string messageId, object[] parameters = null, Exception exception = null) =>
8095
Write(LogLevel.Info, messageId, parameters, exception);
8196

8297
/// <summary>
8398
/// Writes warning message.
8499
/// </summary>
85-
/// <param name="messageId">Identifier of message in resources that should be written to log or message itself.</param>
86-
/// <param name="parameters">Values of parameters in <paramref name="messageId"/> (resource string or message itself).</param>
100+
/// <param name="messageId">
101+
/// Identifier of message in resources that should be written to log or message itself.
102+
/// </param>
103+
/// <param name="parameters">
104+
/// Values of parameters in <paramref name="messageId"/> (resource string or message itself).
105+
/// </param>
87106
/// <param name="exception">Exception, which must be written.</param>
88107
public virtual void Warning(string messageId, object[] parameters = null, Exception exception = null) =>
89108
Write(LogLevel.Warning, messageId, parameters, exception);
90109

91110
/// <summary>
92111
/// Writes error message.
93112
/// </summary>
94-
/// <param name="messageId">Identifier of message in resources that should be written to log or message itself.</param>
95-
/// <param name="parameters">Values of parameters in <paramref name="messageId"/> (resource string or message itself).</param>
113+
/// <param name="messageId">
114+
/// Identifier of message in resources that should be written to log or message itself.
115+
/// </param>
116+
/// <param name="parameters">
117+
/// Values of parameters in <paramref name="messageId"/> (resource string or message itself).
118+
/// </param>
96119
/// <param name="exception">Exception, which must be written.</param>
97120
public virtual void Error(string messageId, object[] parameters = null, Exception exception = null) =>
98121
Write(LogLevel.Error, messageId, parameters, exception);
99122

100123
/// <summary>
101124
/// Writes fatal error message.
102125
/// </summary>
103-
/// <param name="messageId">Identifier of message in resources that should be written to log or message itself.</param>
104-
/// <param name="parameters">Values of parameters in <paramref name="messageId"/>.</param>
126+
/// <param name="messageId">
127+
/// Identifier of message in resources that should be written to log or message itself.
128+
/// </param>
129+
/// <param name="parameters">
130+
/// Values of parameters in <paramref name="messageId"/> (resource string or message itself).
131+
/// </param>
105132
/// <param name="exception">Exception, which must be written.</param>
106133
public virtual void FatalError(string messageId, object[] parameters = null, Exception exception = null) =>
107134
Write(LogLevel.FatalError, messageId, parameters, exception);

Orm/Xtensive.Orm/Orm/Logging/IndentManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2013-2023 Xtensive LLC.
1+
// Copyright (C) 2013-2022 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Denis Krjuchkov

Orm/Xtensive.Orm/Orm/Logging/Internals/ConsoleWriter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2013 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2013-2022 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Alexey Kulakov
55
// Created: 2013.09.27
66

Orm/Xtensive.Orm/Orm/Logging/Internals/DebugOnlyConsoleWriter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2013 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2013-2022 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Alexey Kulakov
55
// Created: 2013.09.27
66

0 commit comments

Comments
 (0)