<commit_before>﻿using Serilog;
using Serilog.Events;

namespace Datalust.Piggy.Cli.Features
{
    class LoggingFeature : CommandFeature
    {
        string _serverUrl, _apiKey;
        LogEventLevel _level = LogEventLevel.Information;

        public override void Enable(OptionSet options)
        {
            options.Add("log-seq=", "Log output to a Seq server at the specified URL", v => _serverUrl = v);
            options.Add("log-seq-apikey=", "If logging to Seq, an optional API key", v => _apiKey = v);
            options.Add("log-debug", "Write additional diagnostic log output", v => _level = LogEventLevel.Debug);
        }

        public void Configure()
        {
            var loggerConfiguration = new LoggerConfiguration()
                .MinimumLevel.Is(_level)
                .WriteTo.Console();

            if (!string.IsNullOrWhiteSpace(_serverUrl))
                loggerConfiguration
                    .Enrich.WithProperty("Application", "Piggy")
                    .WriteTo.Seq(_serverUrl, apiKey: _apiKey);

            Log.Logger = loggerConfiguration.CreateLogger();
        }
    }
}<commit_msg>Invocation<commit_after>﻿using System;
using Serilog;
using Serilog.Events;

namespace Datalust.Piggy.Cli.Features
{
    class LoggingFeature : CommandFeature
    {
        string _serverUrl, _apiKey;
        LogEventLevel _level = LogEventLevel.Information;

        public override void Enable(OptionSet options)
        {
            options.Add("log-seq=", "Log output to a Seq server at the specified URL", v => _serverUrl = v);
            options.Add("log-seq-apikey=", "If logging to Seq, an optional API key", v => _apiKey = v);
            options.Add("log-debug", "Write additional diagnostic log output", v => _level = LogEventLevel.Debug);
        }

        public void Configure()
        {
            var loggerConfiguration = new LoggerConfiguration()
                .MinimumLevel.Is(_level)
                .Enrich.WithProperty("Invocation", Guid.NewGuid())
                .WriteTo.Console();

            if (!string.IsNullOrWhiteSpace(_serverUrl))
                loggerConfiguration
                    .Enrich.WithProperty("Application", "Piggy")
                    .WriteTo.Seq(_serverUrl, apiKey: _apiKey);

            Log.Logger = loggerConfiguration.CreateLogger();
        }
    }
}
{'fraction_non_alphanumeric': 0.1025531914893617, 'fraction_numerical': 0.0, 'mean_word_length': 2.1942934782608696, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1783811', 'n_tokens_mistral': 639, 'n_tokens_neox': 615, 'n_words': 152}