Skip to content

Commit

Permalink
L-733 Rebrand Logtail into BetterStack.Logs.NLog (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrHeinz authored Nov 7, 2023
1 parent f17bc8a commit d600635
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 85 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
bin/*
obj/*
bin/
obj/
global.json

example-project/bin/*
example-project/obj/*
example-project/bin/
example-project/obj/
12 changes: 6 additions & 6 deletions Logtail.csproj → BetterStack.Logs.NLog.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Logtail</PackageId>
<Version>0.2.6</Version>
<PackageId>BetterStack.Logs.NLog</PackageId>
<Version>1.0.0</Version>
<Authors>Simon Rozsival, Tomas Hromada</Authors>
<Company>Better Stack</Company>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>icon.png</PackageIcon>
<PackageProjectUrl>https://logtail.com</PackageProjectUrl>
<RepositoryUrl>https://github.com/logtail/logtail-dotnet</RepositoryUrl>
<PackageProjectUrl>https://logs.betterstack.com</PackageProjectUrl>
<RepositoryUrl>https://github.com/BetterStackHQ/logs-client-nlog</RepositoryUrl>
<RespositoryType>git</RespositoryType>
<Tags>logging logtail livetail nlog</Tags>
<Tags>betterstack logging livetail nlog</Tags>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<DefaultItemExcludes>$(DefaultItemExcludes);example-project/**</DefaultItemExcludes>
<DefaultItemExcludes>$(DefaultItemExcludes);example-project/**;dashboard.png</DefaultItemExcludes>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
using NLog.Targets;
using NLog.Layouts;

namespace Logtail.NLog
namespace BetterStack.Logs.NLog
{
/// <summary>
/// NLog target for Logtail. This target does not send all the events individually
/// to the Logtail server but it sends them periodically in batches.
/// NLog target for Better Stack Logs. This target does not send all the events individually
/// to the Better Stack server but it sends them periodically in batches.
/// </summary>
[Target("Logtail")]
public sealed class LogtailTarget : TargetWithContext
[Target("BetterStack.Logs")]
public sealed class BetterStackLogsTarget : TargetWithContext
{
/// <summary>
/// Gets or sets the Logtail source token.
/// Gets or sets the Better Stack Logs source token.
/// </summary>
/// <value>The source token.</value>
[RequiredParameter]
public Layout SourceToken { get; set; }

/// <summary>
/// The Logtail endpoint.
/// The Better Stack Logs endpoint.
/// </summary>
public Layout Endpoint { get; set; } = "https://in.logtail.com";
public Layout Endpoint { get; set; } = "https://in.logs.betterstack.com";

/// <summary>
/// Maximum logs sent to the server in one batch.
Expand Down Expand Up @@ -79,20 +79,20 @@ public StackTraceUsage StackTraceUsage
}
private StackTraceUsage _stackTraceUsage;

private Drain logtail = null;
private Drain betterStackDrain = null;

/// <summary>
/// Initializes a new instance of the <see cref="LogtailTarget"/> class.
/// Initializes a new instance of the BetterStack.Logs.NLog.BetterStackLogsTarget class.
/// </summary>
public LogtailTarget()
public BetterStackLogsTarget()
{
StackTraceUsage = StackTraceUsage.Max;
}

/// <inheritdoc/>
protected override void InitializeTarget()
{
logtail?.Stop().Wait();
betterStackDrain?.Stop().Wait();

var sourceToken = RenderLogEvent(SourceToken, LogEventInfo.CreateNullEvent());
var endpoint = RenderLogEvent(Endpoint, LogEventInfo.CreateNullEvent());
Expand All @@ -103,7 +103,7 @@ protected override void InitializeTarget()
retries: Retries
);

logtail = new Drain(
betterStackDrain = new Drain(
client,
period: TimeSpan.FromMilliseconds(FlushPeriodMilliseconds),
maxBatchSize: MaxBatchSize
Expand All @@ -115,7 +115,7 @@ protected override void InitializeTarget()
/// <inheritdoc/>
protected override void CloseTarget()
{
logtail?.Stop().Wait();
betterStackDrain?.Stop().Wait();
base.CloseTarget();
}

Expand Down Expand Up @@ -156,7 +156,7 @@ protected override void Write(LogEventInfo logEvent)
Context = contextDictionary
};

logtail.Enqueue(log);
betterStackDrain.Enqueue(log);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using NLog.Layouts;
using NLog.MessageTemplates;

namespace Logtail.NLog
namespace BetterStack.Logs.NLog
{
public class ColorValueFormatter : IValueFormatter
{
Expand Down
7 changes: 3 additions & 4 deletions Logtail/Client.cs → BetterStack.Logs/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

namespace Logtail
namespace BetterStack.Logs
{
/// <summary>
/// The Client class is responsible for reliable delivery of logs
/// to the Logtail servers.
/// The Client class is responsible for reliable delivery of logs to the Better Stack servers.
/// </summary>
public sealed class Client
{
Expand All @@ -25,7 +24,7 @@ public sealed class Client

public Client(
string sourceToken,
string endpoint = "https://in.logtail.com",
string endpoint = "https://in.logs.betterstack.com",
TimeSpan? timeout = null,
int retries = 10
)
Expand Down
4 changes: 2 additions & 2 deletions Logtail/Drain.cs → BetterStack.Logs/Drain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Threading;
using System.Threading.Tasks;

namespace Logtail
namespace BetterStack.Logs
{
/// <summary>
/// The Drain class is responsible for maintaining a queue of log events that need
Expand All @@ -24,7 +24,7 @@ public sealed class Drain
private CancellationTokenSource cancellationTokenSource;

/// <summary>
/// Initializes a Logtail drain and starts periodic logs delivery.
/// Initializes a Better Stack Logs drain and starts periodic logs delivery.
/// </summary>
public Drain(
Client client,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Logtail
namespace BetterStack.Logs
{
public sealed class DrainIsClosedException : Exception
{
Expand Down
2 changes: 1 addition & 1 deletion Logtail/Log.cs → BetterStack.Logs/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Logtail
namespace BetterStack.Logs
{
public sealed class Log
{
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
License

Copyright (c) 2021, Logtail
Copyright (c) 2021, Better Stack, Inc.

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
# [Better Stack](https://betterstack.com/logs) .NET client
# [Better Stack](https://betterstack.com/logs) .NET NLog client

📣 Logtail is now part of Better Stack. [Learn more ⇗](https://betterstack.com/press/introducing-better-stack/)

[![Better Stack dashboard](https://github.com/logtail/logtail-python/assets/10132717/e2a1196b-7924-4abc-9b85-055e17b5d499)](https://betterstack.com/logs)
[![Better Stack dashboard](https://raw.githubusercontent.com/BetterStackHQ/logs-client-nlog/main/dashboard.png)](https://betterstack.com/logs)

[![ISC License](https://img.shields.io/badge/license-ISC-ff69b4.svg)](LICENSE.md)
[![Nuget version](https://badge.fury.io/nu/Logtail.svg)](https://www.nuget.org/packages/Logtail)
[![Nuget version](https://badge.fury.io/nu/BetterStack.Logs.NLog.svg)](https://www.nuget.org/packages/BetterStack.Logs.NLog)

Experience SQL-compatible structured log management based on ClickHouse. [Learn more ⇗](https://betterstack.com/logs)

## Documentation

[Getting started ⇗](https://betterstack.com/docs/logs/net-c/)
[Getting started ⇗](https://betterstack.com/docs/logs/net-c/#send-logs-to-better-stack-using-nlog)

## Need help?
Please let us know at [[email protected]](mailto:[email protected]). We're happy to help!

---

[ISC license](https://github.com/logtail/logtail-dotnet/blob/master/LICENSE.md), [example project](https://github.com/logtail/logtail-dotnet/tree/master/example-project)
[ISC license](LICENSE.md), [example project](example-project/)
Binary file added dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Logtail" Version="0.2.6" />
<PackageReference Include="BetterStack.Logs.NLog" Version="1.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.5" />
</ItemGroup>

Expand Down
30 changes: 15 additions & 15 deletions example-project/Program.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
//This project uses new C# templates to generate top-level statements
// This project uses new C# templates to generate top-level statements
// See https://aka.ms/new-console-template for more information

/**
* This project showcases logging to Logtail
* This project showcases logging to Better Stack
*/

using NLog;

// Configure NLog to color properties based on their type
NLog.Config.ConfigurationItemFactory.Default.ValueFormatter = new Logtail.NLog.ColorValueFormatter();
NLog.Config.ConfigurationItemFactory.Default.ValueFormatter = new BetterStack.Logs.NLog.ColorValueFormatter();

// Create logger for current class
var logger = LogManager.GetCurrentClassLogger();

//Following code showcases 6 NLog's default log levels
//Additionaly, it also show how to structure logs to add additional data
// Following code showcases 6 NLog's default log levels
// Additionaly, it also show how to structure logs to add additional data

//Ttrace the code using the Trace() method
// Trace the code using the Trace() method
logger.Trace("Tracing the code!");

//Send debug messages using the Debug() method
logger.Debug("Debugging is hard, but can be easier with Logtail!");
// Send debug messages using the Debug() method
logger.Debug("Debugging is hard, but can be easier with Better Stack!");

//Send informative messages about application progress using the Info() method
//All of the properties that you pass to the log will be stored in a structured
//form in the context section of the logged event
// Send informative messages about application progress using the Info() method
// All of the properties that you pass to the log will be stored in a structured
// form in the context section of the logged event
logger.Info("User {user} - {userID} just ordered item {item}", "Josh", 95845, 75423);

//Report non-critical issues using the Warn() method
// Report non-critical issues using the Warn() method
logger.Warn("Something is happening!");

//Send message about serious problems using the Error() method
// Send message about serious problems using the Error() method
logger.Error("Error occurred! And it's not good.");

//Report fatal errors that coused application to crash using the Fatal() method
// Report fatal errors that caused application to crash using the Fatal() method
logger.Fatal("Application crashed! Needs to be fixed ASAP!");

Console.WriteLine("All done! Now, you can check Logtail to see your logs");
Console.WriteLine("All done! Now, you can check Better Stack to see your logs");
Loading

0 comments on commit d600635

Please sign in to comment.