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
- Host: GitHub
- URL: https://github.com/goswinr/avalonlog
- Owner: goswinr
- License: mit
- Created: 2021-04-09T13:11:54.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-04-24T05:48:57.000Z (about 2 months ago)
- Last Synced: 2025-04-24T06:32:15.041Z (about 2 months ago)
- Topics: avalonedit, console, fsharp, logging, wpf
- Language: F#
- Homepage: https://goswinr.github.io/AvalonLog/
- Size: 376 KB
- Stars: 9
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README

# AvalonLog[](https://www.nuget.org/packages/AvalonLog/)
[](https://github.com/goswinr/AvalonLog/actions/workflows/build.yml)
[](https://github.com/goswinr/AvalonLog/actions/workflows/docs.yml)
[](https://github.com/goswinr/AvalonLog/actions/workflows/outdatedNuget.yml)
[](https://github.com/goswinr/AvalonLog/actions/workflows/outdatedDotnetTool.yml)
[](LICENSE.md)
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
### 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)