An open API service indexing awesome lists of open source software.

https://github.com/goswinr/avalonlog

A thread-safe and colorful text viewer based on AvalonEdit
https://github.com/goswinr/avalonlog

avalonedit console fsharp logging wpf

Last synced: about 2 months ago
JSON representation

A thread-safe and colorful text viewer based on AvalonEdit

Awesome Lists containing this project

README

        

![Logo](https://raw.githubusercontent.com/goswinr/AvalonLog/main/Docs/img/logo128.png)
# AvalonLog

[![AvalonLog on nuget.org](https://img.shields.io/nuget/v/AvalonLog)](https://www.nuget.org/packages/AvalonLog/)
[![Build Status](https://github.com/goswinr/AvalonLog/actions/workflows/build.yml/badge.svg)](https://github.com/goswinr/AvalonLog/actions/workflows/build.yml)
[![Docs Build Status](https://github.com/goswinr/AvalonLog/actions/workflows/docs.yml/badge.svg)](https://github.com/goswinr/AvalonLog/actions/workflows/docs.yml)
[![Check NuGet](https://github.com/goswinr/AvalonLog/actions/workflows/outdatedNuget.yml/badge.svg)](https://github.com/goswinr/AvalonLog/actions/workflows/outdatedNuget.yml)
[![Check dotnet tools](https://github.com/goswinr/AvalonLog/actions/workflows/outdatedDotnetTool.yml/badge.svg)](https://github.com/goswinr/AvalonLog/actions/workflows/outdatedDotnetTool.yml)
[![license](https://img.shields.io/github/license/goswinr/AvalonLog)](LICENSE.md)
![code size](https://img.shields.io/github/languages/code-size/goswinr/AvalonLog.svg)

AvalonLog is a fast and thread-safe WPF text log viewer for colored text. Including F# `printf` formatting. Based on [AvalonEditB](https://github.com/goswinr/AvalonEditB). Works on .NET Framework 4.7.2 and .NET 7.0+

Thread-safe means that it can be called from any thread.

Fast means

- it buffers repeated print calls and updates the view maximum 20 times per second. see [source](https://github.com/goswinr/AvalonLog/blob/main/Src/AvalonLog.fs#L222)

- Avalonedit is fast, the view is virtualized. It can easily handle thousands of lines.

### Use with F#

Here an short example for F# interactive in .NET Framework.
(for net9 you would have to use it in a project)

```fsharp
#r "PresentationCore"
#r "PresentationFramework"
#r "WindowsBase"

#r "nuget: AvalonLog"

open System.Windows

let log = new AvalonLog.AvalonLog() // The main class wrapping an Avalonedit TextEditor as append only log.

// create some printing functions by partial application:
let red = log.printfColor 255 0 0 // without newline
let blue = log.printfnColor 0 0 255 // with newline
let green = log.printfnColor 0 155 0 // with newline

// print to log using F# printf formatting
red "Hello, "
blue "World!"
red "The answer"
green " is %d." (40 + 2)

Application().Run(Window(Content=log)) // show WPF window
```
this will produce

![WPF window](https://raw.githubusercontent.com/goswinr/AvalonLog/main/Docs/img/HelloWorld.png)

### Use in C#

```csharp
public void AppendWithBrush(SolidColorBrush br, string s)
```
and similar functions on the `AvalonLog` instance.

> [!CAUTION]
> When used from C# add a reference to FSharp.Core 6.0.7 or higher.

### Full API Documentation

[goswinr.github.io/AvalonLog](https://goswinr.github.io/AvalonLog/reference/avalonlog.html)

### Download

AvalonLog is available as [NuGet package](https://www.nuget.org/packages/AvalonLog).

### How to build

Just run `dotnet build`

### Changelog
see [CHANGELOG.md](https://github.com/goswinr/AvalonLog/blob/main/CHANGELOG.md)

### License

[MIT](https://github.com/goswinr/AvalonLog/blob/main/LICENSE.md)

Logo by [LovePik](https://lovepik.com/image-401268798/crystal-parrot-side-cartoon.html)