add loggers

This commit is contained in:
Anton Suhorukov 2022-05-06 18:49:06 +03:00
parent 92c6844810
commit bcb7e9c3e7
34 changed files with 758 additions and 94 deletions

View File

@ -145,7 +145,7 @@ public class DbHelper : IDisposable
var adapter = _factory.CreateDataAdapter();
adapter.SelectCommand = CreateCommand("select " + Quote(table) + ".* from " + Quote(table) + GetWhere(table, tenant));
_logger.LogDebug(adapter.SelectCommand.CommandText);
_logger.Debug(adapter.SelectCommand.CommandText);
adapter.Fill(dataTable);
@ -153,7 +153,7 @@ public class DbHelper : IDisposable
}
catch (Exception error)
{
_logger.LogError(error, "Table {table}", table);
_logger.ErrorTableString(table, error);
throw;
}
}
@ -226,7 +226,7 @@ public class DbHelper : IDisposable
}
catch (Exception e)
{
_logger.LogError(e, "Table {table}", table);
_logger.ErrorTable(table, e);
}
}

View File

@ -83,18 +83,17 @@ public class FileBackupProvider : IBackupProvider
errors++;
if (20 < errors)
{
_logger.LogError(error, "Can not backup file {path}", file.Path);
_logger.ErrorCanNotBackupFile(file.Path, error);
break;
}
}
}
elements.Add(file.ToXElement());
backupKeys.Add(backupPath);
_logger.LogDebug("Backup file {path}", file.Path);
_logger.DebugBackupFile(file.Path);
}
InvokeProgressChanged("Saving file " + file.Path, counter++ / totalCount * 100);
}
return elements;
}
@ -119,7 +118,7 @@ public class FileBackupProvider : IBackupProvider
}
catch (Exception error)
{
_logger.LogError(error, "Can not restore file {0}", file);
_logger.ErrorCanNotRestoreFile(file, error);
}
}
InvokeProgressChanged("Restoring file " + backupInfo.Path, current++ / files.Count() * 100);
@ -172,7 +171,7 @@ public class FileBackupProvider : IBackupProvider
}
catch (Exception error)
{
_logger.LogError(error, "InvokeProgressChanged");
_logger.ErrorInvokeProgressChanged(error);
}
}

View File

@ -68,7 +68,7 @@ public class Schedule
catch (Exception e)
{
var log = _logger;
log.LogError(e, ("Schedule " + backupSchedule.TenantId));
log.ErrorSchedule(backupSchedule.TenantId, e);
return false;
}

View File

@ -33,11 +33,11 @@ global using System.Diagnostics;
global using System.Reflection;
global using System.Security.Cryptography;
global using System.ServiceModel;
global using System.Text;
global using System.Text;
global using System.Text.RegularExpressions;
global using System.Xml;
global using System.Xml.Linq;
global using System.Xml.XPath;
global using System.Xml.XPath;
global using Amazon;
global using Amazon.S3;
@ -47,6 +47,7 @@ global using Amazon.S3.Transfer;
global using ASC.Api.Utils;
global using ASC.Common;
global using ASC.Common.Caching;
global using ASC.Common.Log;
global using ASC.Common.Threading;
global using ASC.Common.Utils;
global using ASC.Core;
@ -60,6 +61,7 @@ global using ASC.Core.Users;
global using ASC.Data.Backup;
global using ASC.Data.Backup.Contracts;
global using ASC.Data.Backup.Core;
global using ASC.Data.Backup.Core.Log;
global using ASC.Data.Backup.EF.Context;
global using ASC.Data.Backup.EF.Model;
global using ASC.Data.Backup.Exceptions;

View File

@ -0,0 +1,107 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Data.Backup.Core.Log;
internal static partial class BackupPortalTaskLogger
{
[LoggerMessage(Level = LogLevel.Debug, Message = "begin backup {tenantId}")]
public static partial void DebugBeginBackup(this ILogger logger, int tenantId);
[LoggerMessage(Level = LogLevel.Debug, Message = "end backup {tenantId}")]
public static partial void DebugEndBackup(this ILogger logger, int tenantId);
[LoggerMessage(Level = LogLevel.Debug, Message = "files: {count}")]
public static partial void DebugFilesCount(this ILogger logger, int count);
[LoggerMessage(Level = LogLevel.Debug, Message = "dir remove start {subDir}")]
public static partial void DebugDirRemoveStart(this ILogger logger, string subDir);
[LoggerMessage(Level = LogLevel.Debug, Message = "dir remove end {subDir}")]
public static partial void DebugDirRemoveEnd(this ILogger logger, string subDir);
[LoggerMessage(Level = LogLevel.Debug, Message = "dump table scheme start {table}")]
public static partial void DebugDumpTableSchemeStart(this ILogger logger, string table);
[LoggerMessage(Level = LogLevel.Debug, Message = "dump table scheme stop {table}")]
public static partial void DebugDumpTableSchemeStop(this ILogger logger, string table);
[LoggerMessage(Level = LogLevel.Debug, Message = "dump table data stop {table}")]
public static partial void DebugDumpTableDataStop(this ILogger logger, string table);
[LoggerMessage(Level = LogLevel.Debug, Message = "dump table data start {table}")]
public static partial void DebugDumpTableDataStart(this ILogger logger, string table);
[LoggerMessage(Level = LogLevel.Debug, Message = "save to file {table}")]
public static partial void DebugSaveTable(this ILogger logger, string table);
[LoggerMessage(Level = LogLevel.Debug, Message = "begin backup storage")]
public static partial void DebugBeginBackupStorage(this ILogger logger);
[LoggerMessage(Level = LogLevel.Debug, Message = "end backup storage")]
public static partial void DebugEndBackupStorage(this ILogger logger);
[LoggerMessage(Level = LogLevel.Debug, Message = "backup file {path}")]
public static partial void DebugBackupFile(this ILogger logger, string path);
[LoggerMessage(Level = LogLevel.Debug, Message = "archive dir start {subDir}")]
public static partial void DebugArchiveDirStart(this ILogger logger, string subDir);
[LoggerMessage(Level = LogLevel.Debug, Message = "archive dir end {subDir}")]
public static partial void DebugArchiveDirEnd(this ILogger logger, string subDir);
[LoggerMessage(Level = LogLevel.Debug, Message = "begin saving data for module {name}")]
public static partial void DebugBeginSavingDataForModule(this ILogger logger, ModuleName name);
[LoggerMessage(Level = LogLevel.Debug, Message = "begin load table {table}")]
public static partial void DebugBeginLoadTable(this ILogger logger, string table);
[LoggerMessage(Level = LogLevel.Debug, Message = "end load table {table}")]
public static partial void DebugEndLoadTable(this ILogger logger, string table);
[LoggerMessage(Level = LogLevel.Debug, Message = "begin saving table {table}")]
public static partial void DebugBeginSavingTable(this ILogger logger, string table);
[LoggerMessage(Level = LogLevel.Debug, Message = "end saving table {table}")]
public static partial void DebugEndSavingTable(this ILogger logger, string table);
[LoggerMessage(Level = LogLevel.Debug, Message = "end saving data for module {table}")]
public static partial void DebugEndSavingDataForModule(this ILogger logger, ModuleName table);
[LoggerMessage(Level = LogLevel.Error, Message = "DumpTableScheme")]
public static partial void ErrorDumpTableScheme(this ILogger logger, Exception exception);
[LoggerMessage(Level = LogLevel.Error, Message = "SelectCount")]
public static partial void ErrorSelectCount(this ILogger logger, Exception exception);
[LoggerMessage(Level = LogLevel.Error, Message = "DumpTableData")]
public static partial void ErrorDumpTableData(this ILogger logger, Exception exception);
[LoggerMessage(Level = LogLevel.Warning, Message = "backup attempt failure")]
public static partial void WarningBackupAttemptFailure(this ILogger logger, Exception exception);
[LoggerMessage(Level = LogLevel.Warning, Message = "can't backup file ({module}:{path})")]
public static partial void WarningCanNotBackupFile(this ILogger logger, string module, string path, Exception exception);
}

View File

@ -0,0 +1,38 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Data.Backup.Core.Log;
internal static partial class BackupProgressItemLogger
{
[LoggerMessage(Level = LogLevel.Error, Message = "RunJob - Params: id: {id}, tenantId: {tenantId}, file: {file}, basePath: {basePath}")]
public static partial void ErrorRunJob(this ILogger logger, string id, int tenantId, string file, string basePath, Exception exception);
[LoggerMessage(Level = LogLevel.Error, Message = "publish")]
public static partial void ErrorPublish(this ILogger logger, Exception exception);
[LoggerMessage(Level = LogLevel.Error, Message = "can't delete file")]
public static partial void ErrorCantDeleteFile(this ILogger logger, Exception exception);
}

View File

@ -0,0 +1,32 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Data.Backup.Core.Log;
internal static partial class BackupServiceLogger
{
[LoggerMessage(Level = LogLevel.Warning, Message = "error while removing backup record")]
public static partial void WarningErrorWhileBackupRecord(this ILogger logger, Exception exception);
}

View File

@ -0,0 +1,32 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Data.Backup.Core.Log;
internal static partial class BackupStorageFactoryLogger
{
[LoggerMessage(Level = LogLevel.Error, Message = "can't get backup storage for record {id}")]
public static partial void ErrorCantGetBackupStorage(this ILogger logger, Guid id, Exception exception);
}

View File

@ -0,0 +1,32 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Data.Backup.Core.Log;
internal static partial class BackupWorkerLogger
{
[LoggerMessage(Level = LogLevel.Warning, Message = "Configuration file {invalidConfigPath} not found")]
public static partial void WarningCanNotBackupFile(this ILogger logger, string invalidConfigPath);
}

View File

@ -0,0 +1,35 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Data.Backup.Core.Log;
public static partial class DbHelperLogger
{
[LoggerMessage(Level = LogLevel.Error, Message = "Table {table}")]
public static partial void ErrorTableString(this ILogger logger, string table, Exception exception);
[LoggerMessage(Level = LogLevel.Error, Message = "Table {table}")]
public static partial void ErrorTable(this ILogger logger, DataTable table, Exception exception);
}

View File

@ -0,0 +1,50 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Data.Backup.Core.Log;
internal static partial class DeletePortalTaskLogging
{
[LoggerMessage(Level = LogLevel.Debug, Message = "begin delete {tenantId}")]
public static partial void DebugBeginDelete(this ILogger logger, int tenantId);
[LoggerMessage(Level = LogLevel.Debug, Message = "end delete {tenantId}")]
public static partial void DebugEndDelete(this ILogger logger, int tenantId);
[LoggerMessage(Level = LogLevel.Debug, Message = "begin delete data for module ({name})")]
public static partial void DebugBeginDeleteDataForModule(this ILogger logger, ModuleName name);
[LoggerMessage(Level = LogLevel.Debug, Message = "end delete data for module ({name})")]
public static partial void DebugEndDeleteDataForModule(this ILogger logger, ModuleName name);
[LoggerMessage(Level = LogLevel.Debug, Message = "begin delete storage")]
public static partial void DebugBeginDeleteStorage(this ILogger logger);
[LoggerMessage(Level = LogLevel.Debug, Message = "end delete storage")]
public static partial void DebugEndDeleteStorage(this ILogger logger);
[LoggerMessage(Level = LogLevel.Warning, Message = "Can't delete files for domain {domain}")]
public static partial void DebugCanNotDeleteFilesForDomain(this ILogger logger, string domain, Exception exception);
}

View File

@ -0,0 +1,38 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Data.Backup.Core.Log;
internal static partial class FileBackupProviderLogger
{
[LoggerMessage(Level = LogLevel.Error, Message = "Can not backup file {path}")]
public static partial void ErrorCanNotBackupFile(this ILogger logger, string path, Exception exception);
[LoggerMessage(Level = LogLevel.Error, Message = "Can not restore file {file}")]
public static partial void ErrorCanNotRestoreFile(this ILogger logger, XElement file, Exception exception);
[LoggerMessage(Level = LogLevel.Error, Message = "InvokeProgressChanged")]
public static partial void ErrorInvokeProgressChanged(this ILogger logger, Exception exception);
}

View File

@ -0,0 +1,35 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Data.Backup.Core.Log;
internal static partial class FilesModuleSpecificsLogger
{
[LoggerMessage(Level = LogLevel.Error, Message = "Can not prepare data {data}")]
public static partial void ErrorCanNotPrepareData(this ILogger logger, string data, Exception exception);
[LoggerMessage(Level = LogLevel.Error, Message = "Can not prepare value {value}")]
public static partial void ErrorCanNotPrepareValue(this ILogger logger, object value, Exception exception);
}

View File

@ -0,0 +1,41 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Data.Backup.Core.Log;
internal static partial class PortalTaskBaseLogger
{
[LoggerMessage(Level = LogLevel.Debug, Message = "Steps: {stepsCount}")]
public static partial void DebugCountSteps(this ILogger logger, int stepsCount);
[LoggerMessage(Level = LogLevel.Debug, Message = "run mysql file {file} {args}")]
public static partial void DebugRunMySQlFile(this ILogger logger, string file, string args);
[LoggerMessage(Level = LogLevel.Debug, Message = "complete mysql file {file}")]
public static partial void DebugCompleteMySQlFile(this ILogger logger, string file);
[LoggerMessage(Level = LogLevel.Error, Message = "Restore")]
public static partial void ErrorRestore(this ILogger logger, Exception exception);
}

View File

@ -0,0 +1,47 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Data.Backup.Core.Log;
internal static partial class RestoreDbModuleTaskLogger
{
[LoggerMessage(Level = LogLevel.Debug, Message = "begin restore data for module {moduleName}")]
public static partial void DebugBeginRestoreDataForModule(this ILogger logger, ModuleName moduleName);
[LoggerMessage(Level = LogLevel.Debug, Message = "begin restore table {tableName}")]
public static partial void DebugBeginRestoreTable(this ILogger logger, string tableName);
[LoggerMessage(Level = LogLevel.Debug, Message = "{rows} rows inserted for table {tableName}")]
public static partial void DebugRowsInserted(this ILogger logger, int rows, string tableName);
[LoggerMessage(Level = LogLevel.Debug, Message = "end restore data for module {moduleName}")]
public static partial void DebugEndRestoreDataForModule(this ILogger logger, ModuleName moduleName);
[LoggerMessage(Level = LogLevel.Warning, Message = "Can't create command to insert row to {tableInfo} with values [{row}]")]
public static partial void WarningCantCreateCommand(this ILogger logger, TableInfo tableInfo, DataRowInfo row);
[LoggerMessage(Level = LogLevel.Warning, Message = "Table {name} does not contain tenant id column. Can't apply low importance relations on such tables.")]
public static partial void WarningTableDoesNotContainTenantIdColumn(this ILogger logger, string name);
}

View File

@ -0,0 +1,62 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Data.Backup.Core.Log;
internal static partial class RestorePortalTaskLogger
{
[LoggerMessage(Level = LogLevel.Debug, Message = "begin restore portal")]
public static partial void DebugBeginRestorePortal(this ILogger logger);
[LoggerMessage(Level = LogLevel.Debug, Message = "begin restore data")]
public static partial void DebugBeginRestoreData(this ILogger logger);
[LoggerMessage(Level = LogLevel.Debug, Message = "end restore data")]
public static partial void DebugEndRestoreData(this ILogger logger);
[LoggerMessage(Level = LogLevel.Debug, Message = "clear cache")]
public static partial void DebugClearCache(this ILogger logger);
[LoggerMessage(Level = LogLevel.Debug, Message = "refresh license")]
public static partial void DebugRefreshLicense(this ILogger logger);
[LoggerMessage(Level = LogLevel.Debug, Message = "end restore portal")]
public static partial void DebugEndRestorePortal(this ILogger logger);
[LoggerMessage(Level = LogLevel.Debug, Message = "begin restore storage")]
public static partial void DebugBeginRestoreStorage(this ILogger logger);
[LoggerMessage(Level = LogLevel.Debug, Message = "end restore storage")]
public static partial void DebugEndRestoreStorage(this ILogger logger);
[LoggerMessage(Level = LogLevel.Debug, Message = "Restore from {fileName}")]
public static partial void DebugRestoreFrom(this ILogger logger, string fileName);
[LoggerMessage(Level = LogLevel.Error, Message = "RunJob")]
public static partial void ErrorRunJob(this ILogger logger, Exception exception);
[LoggerMessage(Level = LogLevel.Warning, Message = "can't restore file ({module}:{path})")]
public static partial void WarningCantRestoreFile(this ILogger logger, string module, string path, Exception exception);
}

View File

@ -0,0 +1,32 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Data.Backup.Core.Log;
internal static partial class RestoreProgressItemLogger
{
[LoggerMessage(Level = LogLevel.Error, Message = "RestoreProgressItem")]
public static partial void ErrorRestoreProgressItem(this ILogger logger, Exception exception);
}

View File

@ -0,0 +1,32 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Data.Backup.Core.Log;
public static partial class ScheduleLogger
{
[LoggerMessage(Level = LogLevel.Error, Message = "Schedule {tenantId}")]
public static partial void ErrorSchedule(this ILogger logger, int tenantId, Exception exception);
}

View File

@ -0,0 +1,50 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Data.Backup.Core.Log;
internal static partial class TransferPortalTaskLogger
{
[LoggerMessage(Level = LogLevel.Debug, Message = "begin transfer {tenantId}")]
public static partial void DebugBeginTransfer(this ILogger logger, int tenantId);
[LoggerMessage(Level = LogLevel.Debug, Message = "end transfer {tenantId}")]
public static partial void DebugEndTransfer(this ILogger logger, int tenantId);
[LoggerMessage(Level = LogLevel.Debug, Message = "begin transfer storage")]
public static partial void DebugBeginTransferStorage(this ILogger logger);
[LoggerMessage(Level = LogLevel.Debug, Message = "end transfer storage")]
public static partial void DebugEndTransferStorage(this ILogger logger);
[LoggerMessage(Level = LogLevel.Error, Message = "TransferProgressItem")]
public static partial void ErrorTransferProgressItem(this ILogger logger, Exception exception);
[LoggerMessage(Level = LogLevel.Warning, Message = "Can't copy file ({module}:{path})")]
public static partial void WarningCantCopyFile(this ILogger logger, string module, string path, Exception exception);
[LoggerMessage(Level = LogLevel.Warning, Message = "Can't adjust file path \"{path}\".")]
public static partial void WarningCantAdjustFilePath(this ILogger logger, string path);
}

View File

@ -89,7 +89,7 @@ public class BackupService : IBackupService
}
catch (Exception error)
{
_logger.LogWarning(error, "error while removing backup record");
_logger.WarningErrorWhileBackupRecord(error);
}
}
}

View File

@ -74,7 +74,7 @@ public class BackupWorker
if (invalidConfigPath != null)
{
_logger.LogWarning("Configuration file {invalidConfigPath} not found", invalidConfigPath);
_logger.WarningCanNotBackupFile(invalidConfigPath);
}
}

View File

@ -193,7 +193,7 @@ public class BackupProgressItem : BaseBackupProgressItem
}
catch (Exception error)
{
Logger.LogError(error, "RunJob - Params: {data}", new { Id, Tenant = TenantId, File = tempFile, BasePath = _storageBasePath, });
Logger.ErrorRunJob(Id, TenantId, tempFile, _storageBasePath, error);
Exception = error;
IsCompleted = true;
}
@ -205,7 +205,7 @@ public class BackupProgressItem : BaseBackupProgressItem
}
catch (Exception error)
{
Logger.LogError(error, "publish");
Logger.ErrorPublish(error);
}
try
@ -217,7 +217,7 @@ public class BackupProgressItem : BaseBackupProgressItem
}
catch (Exception error)
{
Logger.LogError(error, "can't delete file");
Logger.ErrorCantDeleteFile(error);
}
}
}

View File

@ -199,7 +199,7 @@ public class RestoreProgressItem : BaseBackupProgressItem
}
catch (Exception error)
{
Logger.LogError(error, "RestoreProgressItem");
Logger.ErrorRestoreProgressItem(error);
Exception = error;
if (tenant != null)
@ -216,7 +216,7 @@ public class RestoreProgressItem : BaseBackupProgressItem
}
catch (Exception error)
{
Logger.LogError(error, "publish");
Logger.ErrorPublish(error);
}
if (File.Exists(tempFile))

View File

@ -134,7 +134,7 @@ public class TransferProgressItem : BaseBackupProgressItem
}
catch (Exception error)
{
Logger.LogError(error, "TransferProgressItem");
Logger.ErrorTransferProgressItem(error);
Exception = error;
Link = GetLink(alias, true);
@ -148,7 +148,7 @@ public class TransferProgressItem : BaseBackupProgressItem
}
catch (Exception error)
{
Logger.LogError(error, "publish");
Logger.ErrorPublish(error);
}
if (File.Exists(tempFile))

View File

@ -63,7 +63,7 @@ public class BackupStorageFactory
}
catch (Exception error)
{
_logger.LogError(error, ("can't get backup storage for record " + record.Id));
_logger.ErrorCantGetBackupStorage(record.Id, error);
return null;
}

View File

@ -108,7 +108,7 @@ internal class S3BackupStorage : IBackupStorage
}
catch (AmazonS3Exception ex)
{
_logger.LogWarning(ex, "");
_logger.Warning(ex);
return false;
}

View File

@ -71,7 +71,7 @@ public class BackupPortalTask : PortalTaskBase
public override void RunJob()
{
Logger.LogDebug("begin backup {tenantId}", TenantId);
Logger.DebugBeginBackup(TenantId);
_tenantManager.SetCurrentTenant(TenantId);
@ -101,7 +101,7 @@ public class BackupPortalTask : PortalTaskBase
}
}
Logger.LogDebug("end backup {tenantId}", TenantId);
Logger.DebugEndBackup(TenantId);
}
public List<object[]> ExecuteList(DbCommand command)
@ -150,7 +150,7 @@ public class BackupPortalTask : PortalTaskBase
}
stepscount += files.Count * 2 + 1;
Logger.LogDebug("files: {count}", files.Count);
Logger.DebugFilesCount(files.Count);
}
SetStepsCount(stepscount);
@ -198,9 +198,9 @@ public class BackupPortalTask : PortalTaskBase
ArchiveDir(writer, subDir);
}
Logger.LogDebug("dir remove start {subDir}", subDir);
Logger.DebugDirRemoveStart(subDir);
Directory.Delete(subDir, true);
Logger.LogDebug("dir remove end {subDir}", subDir);
Logger.DebugDirRemoveEnd(subDir);
if (ProcessStorage)
{
@ -221,7 +221,7 @@ public class BackupPortalTask : PortalTaskBase
{
try
{
Logger.LogDebug("dump table scheme start {table}", t);
Logger.DebugDumpTableSchemeStart(t);
using (var connection = DbFactory.OpenConnection())
{
var command = connection.CreateCommand();
@ -245,11 +245,11 @@ public class BackupPortalTask : PortalTaskBase
SetStepCompleted();
}
Logger.LogDebug("dump table scheme stop {table}", t);
Logger.DebugDumpTableSchemeStop(t);
}
catch (Exception e)
{
Logger.LogError(e, "DumpTableScheme");
Logger.ErrorDumpTableScheme(e);
throw;
}
@ -270,7 +270,7 @@ public class BackupPortalTask : PortalTaskBase
}
catch (Exception e)
{
Logger.LogError(e, "SelectCount");
Logger.ErrorSelectCount(e);
throw;
}
@ -282,13 +282,13 @@ public class BackupPortalTask : PortalTaskBase
{
if (count == 0)
{
Logger.LogDebug("dump table data stop {table}", t);
Logger.DebugDumpTableDataStop(t);
SetStepCompleted(2);
return;
}
Logger.LogDebug("dump table data start {table}", t);
Logger.DebugDumpTableDataStart(t);
bool searchWithPrimary;
string primaryIndex;
var primaryIndexStep = 0;
@ -375,11 +375,11 @@ public class BackupPortalTask : PortalTaskBase
SetStepCompleted();
Logger.LogDebug("dump table data stop {table}", t);
Logger.DebugDumpTableDataStop(t);
}
catch (Exception e)
{
Logger.LogError(e, "DumpTableData");
Logger.ErrorDumpTableData(e);
throw;
}
}
@ -406,7 +406,7 @@ public class BackupPortalTask : PortalTaskBase
private void SaveToFile(string path, string t, IReadOnlyCollection<string> columns, List<object[]> data)
{
Logger.LogDebug("save to file {table}", t);
Logger.DebugSaveTable(t);
List<object[]> portion;
while ((portion = data.Take(BatchLimit).ToList()).Count > 0)
{
@ -466,7 +466,7 @@ public class BackupPortalTask : PortalTaskBase
private void DoDumpStorage(IDataWriteOperator writer, IReadOnlyList<BackupFileInfo> files)
{
Logger.LogDebug("begin backup storage");
Logger.DebugBeginBackupStorage();
var dir = Path.GetDirectoryName(BackupFilePath);
var subDir = CrossPlatform.PathCombine(dir, Path.GetFileNameWithoutExtension(BackupFilePath));
@ -509,7 +509,7 @@ public class BackupPortalTask : PortalTaskBase
Directory.Delete(subDir, true);
Logger.LogDebug("end backup storage");
Logger.DebugEndBackupStorage();
}
private async Task DoDumpFile(BackupFileInfo file, string dir)
@ -518,7 +518,7 @@ public class BackupPortalTask : PortalTaskBase
var filePath = CrossPlatform.PathCombine(dir, file.GetZipKey());
var dirName = Path.GetDirectoryName(filePath);
Logger.LogDebug("backup file {path}", filePath);
Logger.DebugBackupFile(filePath);
if (!Directory.Exists(dirName) && !string.IsNullOrEmpty(dirName))
{
@ -541,7 +541,7 @@ public class BackupPortalTask : PortalTaskBase
private void ArchiveDir(IDataWriteOperator writer, string subDir)
{
Logger.LogDebug("archive dir start {subDir}", subDir);
Logger.DebugArchiveDirStart(subDir);
foreach (var enumerateFile in Directory.EnumerateFiles(subDir, "*", SearchOption.AllDirectories))
{
var f = enumerateFile;
@ -558,7 +558,7 @@ public class BackupPortalTask : PortalTaskBase
SetStepCompleted();
}
Logger.LogDebug("archive dir end {subDir}", subDir);
Logger.DebugArchiveDirEnd(subDir);
}
private List<IGrouping<string, BackupFileInfo>> GetFilesGroup()
@ -573,7 +573,7 @@ public class BackupPortalTask : PortalTaskBase
private void DoBackupModule(IDataWriteOperator writer, IModuleSpecifics module)
{
Logger.LogDebug("begin saving data for module {name}", module.ModuleName);
Logger.DebugBeginSavingDataForModule(module.ModuleName);
var tablesToProcess = module.Tables.Where(t => !_ignoredTables.Contains(t.Name) && t.InsertMethod != InsertMethod.None).ToList();
var tablesCount = tablesToProcess.Count;
var tablesProcessed = 0;
@ -582,7 +582,7 @@ public class BackupPortalTask : PortalTaskBase
{
foreach (var table in tablesToProcess)
{
Logger.LogDebug("begin load table {table}", table.Name);
Logger.DebugBeginLoadTable(table.Name);
using (var data = new DataTable(table.Name))
{
ActionInvoker.Try(
@ -604,7 +604,7 @@ public class BackupPortalTask : PortalTaskBase
table,
maxAttempts: 5,
onFailure: error => { throw ThrowHelper.CantBackupTable(table.Name, error); },
onAttemptFailure: error => Logger.LogWarning(error, "backup attempt failure"));
onAttemptFailure: error => Logger.WarningBackupAttemptFailure(error));
foreach (var col in data.Columns.Cast<DataColumn>().Where(col => col.DataType == typeof(DateTime)))
{
@ -613,9 +613,9 @@ public class BackupPortalTask : PortalTaskBase
module.PrepareData(data);
Logger.LogDebug("end load table {table}", table.Name);
Logger.DebugEndLoadTable(table.Name);
Logger.LogDebug("begin saving table {table}", table.Name);
Logger.DebugBeginSavingTable(table.Name);
using (var file = _tempStream.Create())
{
@ -625,19 +625,19 @@ public class BackupPortalTask : PortalTaskBase
writer.WriteEntry(KeyHelper.GetTableZipKey(module, data.TableName), file);
}
Logger.LogDebug("end saving table {table}", table.Name);
Logger.DebugEndSavingTable(table.Name);
}
SetCurrentStepProgress((int)(++tablesProcessed * 100 / (double)tablesCount));
}
}
Logger.LogDebug("end saving data for module {table}", module.ModuleName);
Logger.DebugEndSavingDataForModule(module.ModuleName);
}
private void DoBackupStorage(IDataWriteOperator writer, List<IGrouping<string, BackupFileInfo>> fileGroups)
{
Logger.LogDebug("begin backup storage");
Logger.DebugBeginBackupStorage();
foreach (var group in fileGroups)
{
@ -653,7 +653,7 @@ public class BackupPortalTask : PortalTaskBase
var f = (BackupFileInfo)state;
using var fileStream = storage.GetReadStreamAsync(f.Domain, f.Path).Result;
writer.WriteEntry(file1.GetZipKey(), fileStream);
}, file, 5, error => Logger.LogWarning(error, "can't backup file ({module}:{path})", file1.Module, file1.Path));
}, file, 5, error => Logger.WarningCanNotBackupFile (file1.Module, file1.Path, error));
SetCurrentStepProgress((int)(++filesProcessed * 100 / (double)filesCount));
}
@ -671,7 +671,7 @@ public class BackupPortalTask : PortalTaskBase
writer.WriteEntry(KeyHelper.GetStorageRestoreInfoZipKey(), tmpFile);
}
Logger.LogDebug("end backup storage");
Logger.DebugEndBackupStorage();
}
}

View File

@ -43,7 +43,7 @@ public class DeletePortalTask : PortalTaskBase
public override void RunJob()
{
Logger.LogDebug("begin delete {tenantId}", TenantId);
Logger.DebugBeginDelete(TenantId);
var modulesToProcess = GetModulesToProcess().Reverse().ToList();
SetStepsCount(ProcessStorage ? modulesToProcess.Count + 1 : modulesToProcess.Count);
@ -57,12 +57,12 @@ public class DeletePortalTask : PortalTaskBase
DoDeleteStorage();
}
Logger.LogDebug("end delete {tenantId}", TenantId);
Logger.DebugEndDelete(TenantId);
}
private void DoDeleteModule(IModuleSpecifics module)
{
Logger.LogDebug("begin delete data for module ({name})", module.ModuleName);
Logger.DebugBeginDeleteDataForModule(module.ModuleName);
var tablesCount = module.Tables.Count();
var tablesProcessed = 0;
using (var connection = DbFactory.OpenConnection())
@ -78,12 +78,12 @@ public class DeletePortalTask : PortalTaskBase
}
}
Logger.LogDebug("end delete data for module ({name})", module.ModuleName);
Logger.DebugEndDeleteDataForModule(module.ModuleName);
}
private void DoDeleteStorage()
{
Logger.LogDebug("begin delete storage");
Logger.DebugBeginDeleteStorage();
var storageModules = StorageFactoryConfig.GetModuleList(ConfigPath).Where(IsStorageModuleAllowed).ToList();
var modulesProcessed = 0;
foreach (var module in storageModules)
@ -93,12 +93,12 @@ public class DeletePortalTask : PortalTaskBase
foreach (var domain in domains)
{
ActionInvoker.Try(state => storage.DeleteFilesAsync((string)state, "\\", "*.*", true).Wait(), domain, 5,
onFailure: error => Logger.LogWarning(error, "Can't delete files for domain {domain}", domain));
onFailure: error => Logger.DebugCanNotDeleteFilesForDomain(domain, error));
}
storage.DeleteFilesAsync("\\", "*.*", true).Wait();
SetCurrentStepProgress((int)(++modulesProcessed * 100 / (double)storageModules.Count));
}
Logger.LogDebug("end delete storage");
Logger.DebugEndDeleteStorage();
}
}

View File

@ -145,7 +145,7 @@ public class FilesModuleSpecifics : ModuleSpecificsBase
}
catch (Exception ex)
{
_logger.LogError(ex, "Can not prepare data {data}", row[providerColumn] as string);
_logger.ErrorCanNotPrepareData(row[providerColumn] as string, ex);
data.Rows.Remove(row);
i--;
}
@ -269,7 +269,7 @@ public class FilesModuleSpecifics : ModuleSpecificsBase
}
catch (Exception err)
{
_logger.LogError(err, "Can not prepare value {0}", value);
_logger.ErrorCanNotPrepareValue(value, err);
value = null;
}
return true;

View File

@ -123,7 +123,7 @@ internal class MailModuleSpecifics : ModuleSpecificsBase
}
catch (Exception ex)
{
_logger.LogError(ex, "Can not prepare data {data}", row[address] as string);
_logger.ErrorCanNotPrepareData(row[address] as string, ex);
data.Rows.Remove(row);
i--;
}
@ -292,7 +292,7 @@ internal class MailModuleSpecifics : ModuleSpecificsBase
}
catch (Exception err)
{
_logger.LogError(err, "Can not prepare value {value}", value);
_logger.ErrorCanNotPrepareValue(value, err);
value = null;
}

View File

@ -160,7 +160,7 @@ public abstract class PortalTaskBase
throw new ArgumentOutOfRangeException(nameof(value));
}
_stepsCount = value;
Logger.LogDebug("Steps: {stepsCount}", +_stepsCount);
Logger.DebugCountSteps(+_stepsCount);
}
protected void SetStepCompleted(int increment = 1)
@ -247,7 +247,7 @@ public abstract class PortalTaskBase
}
args.Append($"-e \" source {file}\"");
Logger.LogDebug("run mysql file {file} {args}", file, args.ToString());
Logger.DebugRunMySQlFile(file, args.ToString());
var startInfo = new ProcessStartInfo
{
@ -267,11 +267,11 @@ public abstract class PortalTaskBase
proc.WaitForExit();
var error = proc.StandardError.ReadToEnd();
Logger.LogError((!string.IsNullOrEmpty(error) ? error : proc.StandardOutput.ReadToEnd()));
Logger.Error(!string.IsNullOrEmpty(error) ? error : proc.StandardOutput.ReadToEnd());
}
}
Logger.LogDebug("complete mysql file {file}", file);
Logger.DebugCompleteMySQlFile(file);
}
protected Task RunMysqlFile(Stream stream, string delimiter = ";")
@ -313,7 +313,7 @@ public abstract class PortalTaskBase
}
catch (Exception e)
{
Logger.LogError(e, "Restore");
Logger.ErrorRestore(e);
}
}
}

View File

@ -60,14 +60,14 @@ internal class RestoreDbModuleTask : PortalTaskBase
public override void RunJob()
{
Logger.LogDebug("begin restore data for module {moduleName}", _module.ModuleName);
Logger.DebugBeginRestoreDataForModule(_module.ModuleName);
SetStepsCount(_module.Tables.Count(t => !_ignoredTables.Contains(t.Name)));
using (var connection = DbFactory.OpenConnection())
{
foreach (var table in _module.GetTablesOrdered().Where(t => !_ignoredTables.Contains(t.Name) && t.InsertMethod != InsertMethod.None))
{
Logger.LogDebug("begin restore table {tableName}", table.Name);
Logger.DebugBeginRestoreTable(table.Name);
var transactionsCommited = 0;
var rowsInserted = 0;
@ -79,11 +79,11 @@ internal class RestoreDbModuleTask : PortalTaskBase
onFailure: error => { throw ThrowHelper.CantRestoreTable(table.Name, error); });
SetStepCompleted();
Logger.LogDebug("{rows} rows inserted for table {tableName}", rowsInserted, table.Name);
Logger.DebugRowsInserted(rowsInserted, table.Name);
}
}
Logger.LogDebug("end restore data for module {moduleName}", _module.ModuleName);
Logger.DebugEndRestoreDataForModule(_module.ModuleName);
}
public string[] ExecuteArray(DbCommand command)
@ -163,7 +163,7 @@ internal class RestoreDbModuleTask : PortalTaskBase
row);
if (insertCommand == null)
{
Logger.LogWarning("Can't create command to insert row to {tableInfo} with values [{row}]", tableInfo, row);
Logger.WarningCantCreateCommand(tableInfo, row);
_columnMapper.Rollback();
continue;
@ -185,7 +185,7 @@ internal class RestoreDbModuleTask : PortalTaskBase
{
if (!relation.Item2.HasTenantColumn())
{
Logger.LogWarning("Table {name} does not contain tenant id column. Can't apply low importance relations on such tables.", relation.Item2.Name);
Logger.WarningTableDoesNotContainTenantIdColumn(relation.Item2.Name);
continue;
}

View File

@ -78,9 +78,9 @@ public class RestorePortalTask : PortalTaskBase
public override void RunJob()
{
Logger.LogDebug("begin restore portal");
Logger.DebugBeginRestorePortal();
Logger.LogDebug("begin restore data");
Logger.DebugBeginRestoreData();
using (var dataReader = new ZipReadOperator(BackupFilePath))
{
@ -112,13 +112,13 @@ public class RestorePortalTask : PortalTaskBase
}
}
Logger.LogDebug("end restore data");
Logger.DebugEndRestoreData();
if (ProcessStorage)
{
if (_coreBaseSettings.Standalone)
{
Logger.LogDebug("clear cache");
Logger.DebugClearCache();
_ascCacheNotify.ClearCache();
}
@ -133,21 +133,21 @@ public class RestorePortalTask : PortalTaskBase
if (_coreBaseSettings.Standalone)
{
Logger.LogDebug("refresh license");
Logger.DebugRefreshLicense();
try
{
_licenseReader.RejectLicense();
}
catch (Exception ex)
{
Logger.LogError(ex, "RunJob");
Logger.ErrorRunJob(ex);
}
Logger.LogDebug("clear cache");
Logger.DebugClearCache();
_ascCacheNotify.ClearCache();
}
Logger.LogDebug("end restore portal");
Logger.DebugEndRestorePortal();
}
private void RestoreFromDump(IDataReadOperator dataReader)
@ -204,7 +204,7 @@ public class RestorePortalTask : PortalTaskBase
private async Task RestoreFromDumpFile(IDataReadOperator dataReader, string fileName)
{
Logger.LogDebug("Restore from {fileName}", fileName);
Logger.DebugRestoreFrom(fileName);
using (var stream = dataReader.GetEntry(fileName))
{
await RunMysqlFile(stream);
@ -264,7 +264,7 @@ public class RestorePortalTask : PortalTaskBase
private void DoRestoreStorage(IDataReadOperator dataReader)
{
Logger.LogDebug("begin restore storage");
Logger.DebugBeginRestoreStorage();
var fileGroups = GetFilesToProcess(dataReader).GroupBy(file => file.Module).ToList();
var groupsProcessed = 0;
@ -294,7 +294,7 @@ public class RestorePortalTask : PortalTaskBase
}
catch (Exception error)
{
Logger.LogWarning(error, "can't restore file ({module}:{path})", file.Module, file.Path);
Logger.WarningCantRestoreFile(file.Module, file.Path, error);
}
}
}
@ -315,12 +315,12 @@ public class RestorePortalTask : PortalTaskBase
SetStepCompleted();
}
Logger.LogDebug("end restore storage");
Logger.DebugEndRestoreStorage();
}
private void DoDeleteStorage(IEnumerable<string> storageModules, IEnumerable<Tenant> tenants)
{
Logger.LogDebug("begin delete storage");
Logger.DebugBeginDeleteStorage();
foreach (var tenant in tenants)
{
@ -343,7 +343,7 @@ public class RestorePortalTask : PortalTaskBase
},
domain,
5,
onFailure: error => Logger.LogWarning(error, "Can't delete files for domain {domain}", domain)
onFailure: error => Logger.DebugCanNotDeleteFilesForDomain(domain, error)
);
}
@ -351,7 +351,7 @@ public class RestorePortalTask : PortalTaskBase
}
}
Logger.LogDebug("end delete storage");
Logger.DebugEndDeleteStorage();
}
private IEnumerable<BackupFileInfo> GetFilesToProcess(IDataReadOperator dataReader)

View File

@ -76,7 +76,7 @@ public class TransferPortalTask : PortalTaskBase
public override void RunJob()
{
Logger.LogDebug("begin transfer {tenantId}", TenantId);
Logger.DebugBeginTransfer(TenantId);
var fromDbFactory = new DbFactory(null, null);
var toDbFactory = new DbFactory(null, null);
var tenantAlias = GetTenantAlias(fromDbFactory);
@ -149,13 +149,13 @@ public class TransferPortalTask : PortalTaskBase
{
File.Delete(backupFilePath);
}
Logger.LogDebug("end transfer {tenantId}", TenantId);
Logger.DebugEndTransfer(TenantId);
}
}
private void DoTransferStorage(ColumnMapper columnMapper)
{
Logger.LogDebug("begin transfer storage");
Logger.DebugBeginTransferStorage();
var fileGroups = GetFilesToProcess(TenantId).GroupBy(file => file.Module).ToList();
var groupsProcessed = 0;
foreach (var group in fileGroups)
@ -177,12 +177,12 @@ public class TransferPortalTask : PortalTaskBase
}
catch (Exception error)
{
Logger.LogWarning(error, "Can't copy file ({module}:{path})", file.Module, file.Path);
Logger.WarningCantCopyFile(file.Module, file.Path, error);
}
}
else
{
Logger.LogWarning("Can't adjust file path \"{path}\".", file.Path);
Logger.WarningCantAdjustFilePath(file.Path);
}
}
SetCurrentStepProgress((int)(++groupsProcessed * 100 / (double)fileGroups.Count));
@ -193,7 +193,7 @@ public class TransferPortalTask : PortalTaskBase
SetStepCompleted();
}
Logger.LogDebug("end transfer storage");
Logger.DebugEndTransferStorage();
}
private void SaveTenant(DbFactory dbFactory, string alias, TenantStatus status, string newAlias = null, string whereCondition = null)