Skip to content

Commit

Permalink
Issue/412 (#441)
Browse files Browse the repository at this point in the history
* (#412) Replace NLogger with Serilog

* (maint) Bump version

* (#412) Implements Microsoft.Extensions.Logging
  • Loading branch information
jibedoubleve authored Jan 3, 2024
1 parent 3724d07 commit 7d782f8
Show file tree
Hide file tree
Showing 132 changed files with 1,260 additions and 1,240 deletions.
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
assembly-versioning-scheme: MajorMinorPatchTag
next-version: 2.5.0
next-version: 2.6.0
branches:
master:
is-release-branch: true
Expand Down
Empty file added identifier.sqlite
Empty file.
1 change: 1 addition & 0 deletions src/Lanceur.Core/Lanceur.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Lanceur.Core.Plugins" Version="2.4.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lanceur.SharedKernel\Lanceur.SharedKernel.csproj" />
Expand Down
8 changes: 6 additions & 2 deletions src/Lanceur.Core/LuaScripting/Script.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ public class Script

public ScriptContext Context { get; init; }

public ScriptResult EmptyResult => new ScriptResult
#endregion Properties

#region Methods

public ScriptResult CloneWithoutContext() => new()
{
Code = Code,
Context = ScriptContext.Empty
};

#endregion Properties
#endregion Methods
}
}
4 changes: 2 additions & 2 deletions src/Lanceur.Core/LuaScripting/ScriptContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ public class ScriptContext
#region Properties

public static ScriptContext Empty => new();
public string FileName { get; set; }
public string Parameters { get; set; }
public string FileName { get; init; }
public string Parameters { get; init; }

#endregion Properties
}
Expand Down
7 changes: 6 additions & 1 deletion src/Lanceur.Core/LuaScripting/ScriptResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ public class ScriptResult : Script
#region Properties

public string Error { get; init; }

#endregion Properties

#region Methods

public override string ToString()
{
return $"File Name : {Context.FileName}" +
$"\nParameters : {Context.Parameters}";
}

#endregion Properties
#endregion Methods
}
}
4 changes: 1 addition & 3 deletions src/Lanceur.Core/Managers/IFavIconManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Lanceur.Core.Models;

namespace Lanceur.Core.Managers
namespace Lanceur.Core.Managers
{
public interface IFavIconManager
{
Expand Down
11 changes: 5 additions & 6 deletions src/Lanceur.Core/Models/AliasQueryResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,15 @@ public override bool IsElevated

public bool IsHidden { get; set; }

public string Notes { get; set; }

public RunAs RunAs { get; set; } = RunAs.CurrentUser;

/// <summary>
/// Gets or sets a Lua script that will be executed
/// when user launch an alias
/// </summary>
public string LuaScript { get; set; }

public string Notes { get; set; }

public RunAs RunAs { get; set; } = RunAs.CurrentUser;
public StartMode StartMode { get; set; } = StartMode.Default;

/// <summary>
Expand All @@ -90,8 +89,8 @@ public string Synonyms
/// New synonyms added when updated
/// </summary>
public string SynonymsToAdd => (from n in Synonyms.SplitCsv()
where !SynonymsWhenLoaded.SplitCsv().Contains(n)
select n).ToArray().JoinCsv();
where !SynonymsWhenLoaded.SplitCsv().Contains(n)
select n).ToArray().JoinCsv();

/// <summary>
/// Synonyms present when the entity was loaded
Expand Down
16 changes: 8 additions & 8 deletions src/Lanceur.Core/Models/AliasQueryResultMixin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ public static class AliasQueryResultMixin
{
#region Methods

/// <summary>
/// Indicates whether this alias is a packaged application (i.e: UWP)
/// </summary>
/// <param name="alias">The alias ti check</param>
/// <returns><c>True</c> if this is a packaged application; otherwise <c>False</c></returns>
public static bool IsPackagedApplication(this AliasQueryResult alias)
=> alias.FileName.ToLower().StartsWith("package:");

/// <summary>
/// Set first names defined in the synonyms as the name of the alias
/// </summary>
Expand All @@ -17,13 +25,5 @@ public static void SetName(this AliasQueryResult alias)
.FirstOrDefault();
}

/// <summary>
/// Indicates whether this alias is a packaged application (i.e: UWP)
/// </summary>
/// <param name="alias">The alias ti check</param>
/// <returns><c>True</c> if this is a packaged application; otherwise <c>False</c></returns>
public static bool IsPackagedApplication(this AliasQueryResult alias)
=> alias.FileName.ToLower().StartsWith("package:");

#endregion Methods
}
6 changes: 3 additions & 3 deletions src/Lanceur.Core/Models/DisplayQueryResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public DisplayQueryResult(string name, string description = null, string iconKin

#region Properties

public static IEnumerable<QueryResult> NoResultFound
=> SingleFromResult("No result found", iconKind: "AlertCircleOutline");

public override string Description => _description;

public override bool IsResult => false;
Expand All @@ -37,9 +40,6 @@ public static IEnumerable<QueryResult> SingleFromResult(string text, string subt
};
}

public static IEnumerable<QueryResult> NoResultFound
=> SingleFromResult("No result found", iconKind: "AlertCircleOutline");

#endregion Methods
}
}
10 changes: 5 additions & 5 deletions src/Lanceur.Core/Models/PluginExecutableQueryResult.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
using Lanceur.Core.Plugins;
using Lanceur.Core.Plugins.Models;
using Lanceur.Core.Services;
using Lanceur.SharedKernel.Mixins;
using Microsoft.Extensions.Logging;

namespace Lanceur.Core.Models
{
public sealed class PluginExecutableQueryResult : SelfExecutableQueryResult
{
#region Fields

private readonly IAppLogger _log;
private readonly ILogger<PluginExecutableQueryResult> _logger;
private readonly IPlugin _plugin;

#endregion Fields

#region Constructors

public PluginExecutableQueryResult(IPlugin plugin, IAppLoggerFactory logFactory)
public PluginExecutableQueryResult(IPlugin plugin, ILoggerFactory loggerFactory)
{
_log = logFactory.GetLogger<PluginExecutableQueryResult>();
_logger = loggerFactory.CreateLogger<PluginExecutableQueryResult>();
_plugin = plugin;
Name = plugin.Name;
Icon = plugin.Icon;
Expand Down Expand Up @@ -49,7 +49,7 @@ public override async Task<IEnumerable<QueryResult>> ExecuteAsync(Cmdline cmdlin
{
if (cmdline == null || cmdline.Name.IsNullOrWhiteSpace())
{
_log.Info($"Cannot execute plugin '{Name}': the cmdline is empty.");
_logger.LogInformation("Cannot execute plugin {Name}: the cmdline is empty", Name);
return NoResult;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Lanceur.Core/Models/QueryResultMixin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static class QueryResultMixin
public static string GetMacroName(this AliasQueryResult @this)
{
if (@this is null) return string.Empty;

var regex = new Regex("@(.*)@");
var result = regex.IsMatch(@this.FileName ?? string.Empty)
? regex.Match(@this.FileName ?? string.Empty).Groups[1].Value
Expand Down
10 changes: 5 additions & 5 deletions src/Lanceur.Core/Models/SessionExecutableQueryResult.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Lanceur.Core.Repositories;
using Lanceur.Core.Services;
using Microsoft.Extensions.Logging;

namespace Lanceur.Core.Models
{
public class SessionExecutableQueryResult : SelfExecutableQueryResult
{
#region Fields

private readonly IAppLogger _log;
private readonly ILogger<SessionExecutableQueryResult> _logger;
private readonly IDbRepository _service;

#endregion Fields
Expand All @@ -17,10 +17,10 @@ public class SessionExecutableQueryResult : SelfExecutableQueryResult
public SessionExecutableQueryResult(
string name,
string description,
IAppLoggerFactory logFactory,
ILogger<SessionExecutableQueryResult> logger,
IDbRepository service) : base(name, description)
{
_log = logFactory.GetLogger<SessionExecutableQueryResult>();
_logger = logger;
_service = service;
}

Expand All @@ -30,7 +30,7 @@ public SessionExecutableQueryResult(

public override Task<IEnumerable<QueryResult>> ExecuteAsync(Cmdline cmdline = null)
{
_log.Trace($"Change to session '{Name}' with id {Id}");
_logger.LogInformation("Change to session {Name} with id {Id}", Name, Id);
_service.SetDefaultSession(Id);
return NoResultAsync;
}
Expand Down
16 changes: 8 additions & 8 deletions src/Lanceur.Core/Repositories/IDbRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ public interface IDbRepository
{
#region Methods

/// <summary>
/// Returns all the names that exists in the database AND in the specified list of <see cref="names"/>
/// </summary>
/// <param name="names">The names to find in the database</param>
/// <param name="idSession">The id of the session. If not specified, will take default session</param>
/// <returns></returns>
public ExistingNameResponse SelectNames(string[] names, long? idSession = null);

/// <summary>
/// Get all the aliases
/// </summary>
Expand Down Expand Up @@ -147,6 +139,14 @@ public interface IDbRepository
/// <returns>Resulting aliases</returns>
IEnumerable<AliasQueryResult> SearchAliasWithAdditionalParameters(string criteria, long? idSession = null);

/// <summary>
/// Returns all the names that exists in the database AND in the specified list of <see cref="names"/>
/// </summary>
/// <param name="names">The names to find in the database</param>
/// <param name="idSession">The id of the session. If not specified, will take default session</param>
/// <returns></returns>
public ExistingNameResponse SelectNames(string[] names, long? idSession = null);

void SetDefaultSession(long idSession);

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/Lanceur.Core/Requests/ExecutionRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ public class ExecutionRequest
public QueryResult QueryResult { get; init; }

#endregion Properties

}
}
25 changes: 0 additions & 25 deletions src/Lanceur.Core/Services/IAppLogger.cs

This file was deleted.

13 changes: 0 additions & 13 deletions src/Lanceur.Core/Services/IAppLoggerFactory.cs

This file was deleted.

56 changes: 0 additions & 56 deletions src/Lanceur.Core/Services/TraceLogger.cs

This file was deleted.

Loading

0 comments on commit 7d782f8

Please sign in to comment.