// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System; using log4net; using Ringtoets.Common.IO.Properties; namespace Ringtoets.Common.IO.Configurations.Helpers { /// /// Extension methods for for logging problems occuring during import or export of configurations. /// public static class ILogExtensions { /// /// Logs an out of range exception that was thrown when converting configuration to actual data model instances. /// /// The to use for logging. /// Part of the message that precedes the out of range error message. /// The name of the calculation for which the exception was thrown. /// The exception that was thrown. public static void LogOutOfRangeException(this ILog log, string errorMessage, string calculationName, ArgumentOutOfRangeException exception) { log.LogCalculationConversionError($"{errorMessage} {exception.Message}", calculationName); } /// /// Logs a message for an error which occured when converting configuration to actual data model instances. /// /// The to use for logging. /// The error message to log. /// The name of the calculation for which the error occured. public static void LogCalculationConversionError(this ILog log, string errorMessage, string calculationName) { log.ErrorFormat(Resources.ILogExtensions_LogCalculationConversionError_ErrorMessage_0_Calculation_1_skipped, errorMessage, calculationName); } } }