Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Housekeeping #1

Merged
merged 17 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project>
<PropertyGroup>
<WarningsAsErrors>true</WarningsAsErrors>
<LangVersion>11</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MinVer" Version="4.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
4 changes: 3 additions & 1 deletion Hangfire.Console.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{436BABB0-DBF
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{657DF223-42EC-4765-990B-334C62F602EA}"
ProjectSection(SolutionItems) = preProject
appveyor.yml = appveyor.yml
dashboard.png = dashboard.png
README.md = README.md
Directory.Build.props = Directory.Build.props
hangfire.console.png = hangfire.console.png
LICENSE.md = LICENSE.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CBD2EEC6-826C-4477-B8F7-EADE2D944B74}"
Expand Down
1 change: 1 addition & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2016 Alexey Skalozub
Copyright (c) 2023 IdentityStream AS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
49 changes: 32 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
# Hangfire.Console
# IdentityStream.Hangfire.Console

[![Build status](https://ci.appveyor.com/api/projects/status/b57hb7438d7dvxa2/branch/master?svg=true&passingText=master%20%u2714)](https://ci.appveyor.com/project/pieceofsummer/hangfire-console/branch/master)
[![NuGet](https://img.shields.io/nuget/v/Hangfire.Console.svg)](https://www.nuget.org/packages/Hangfire.Console/)
[![Build Status](https://github.com/IdentityStream/Hangfire.Console/actions/workflows/dotnet.yml/badge.svg)](https://github.com/IdentityStream/Hangfire.Console/actions/workflows/dotnet.yml)
[![NuGet](https://img.shields.io/nuget/v/IdentityStream.Hangfire.Console.svg)](https://www.nuget.org/packages/IdentityStream.Hangfire.Console/)
![MIT License](https://img.shields.io/badge/license-MIT-orange.svg)

Inspired by AppVeyor, Hangfire.Console provides a console-like logging experience for your jobs.
Inspired by AppVeyor, Hangfire.Console provides a console-like logging experience for your jobs.

> [!IMPORTANT]
> As [Hangfire.Console](https://github.com/pieceofsummer/Hangfire.Console) seems to be abandoned, this is a fork with some crucial bugfixes.
> If, at some point in the future, the main project comes back to life, these fixes should probably be merged back upstream.

![dashboard](dashboard.png)

## Features

- **Provider-agnostic**: (allegedly) works with any job storage provider (currently tested with SqlServer and MongoDB).
- **100% Safe**: no Hangfire-managed data (e.g. jobs, states) is ever updated, hence there's no risk to corrupt it.
- **With Live Updates**: new messages will appear as they're logged, as if you're looking at real console.
- (blah-blah-blah)
- **Provider-agnostic**: (allegedly) works with any job storage provider (currently tested with SqlServer and MongoDB).
- **100% Safe**: no Hangfire-managed data (e.g. jobs, states) is ever updated, hence there's no risk to corrupt it.
- **With Live Updates**: new messages will appear as they're logged, as if you're looking at real console.
- (blah-blah-blah)

## Setup

In .NET Core's Startup.cs:

```c#
public void ConfigureServices(IServiceCollection services)
{
Expand All @@ -30,35 +35,39 @@ public void ConfigureServices(IServiceCollection services)
```

Otherwise,

```c#
GlobalConfiguration.Configuration
.UseSqlServerStorage("connectionSting")
.UseConsole();
```

**NOTE**: If you have Dashboard and Server running separately,
**NOTE**: If you have Dashboard and Server running separately,
you'll need to call `UseConsole()` on both.

### Additional options

As usual, you may provide additional options for `UseConsole()` method.

Here's what you can configure:

- **ExpireIn** – time to keep console sessions (default: 24 hours)
- **FollowJobRetentionPolicy** – expire all console sessions along with parent job (default: true)
- **PollInterval** – poll interval for live updates, ms (default: 1000)
- **BackgroundColor** – console background color (default: #0d3163)
- **TextColor** – console default text color (default: #ffffff)
- **TimestampColor** – timestamp text color (default: #00aad7)

**NOTE**: After you initially add Hangfire.Console (or change the options above) you may need to clear browser cache, as generated CSS/JS can be cached by browser.
**NOTE**: After you initially add Hangfire.Console (or change the options above) you may need to clear browser cache, as
generated CSS/JS can be cached by browser.

## Log

Hangfire.Console provides extension methods on `PerformContext` object,
hence you'll need to add it as a job argument.
Hangfire.Console provides extension methods on `PerformContext` object,
hence you'll need to add it as a job argument.

**NOTE**: Like `IJobCancellationToken`, `PerformContext` is a special argument type which Hangfire will substitute automatically. You should pass `null` when enqueuing a job.
**NOTE**: Like `IJobCancellationToken`, `PerformContext` is a special argument type which Hangfire will substitute
automatically. You should pass `null` when enqueuing a job.

Now you can write to console:

Expand Down Expand Up @@ -99,11 +108,13 @@ public void TaskMethod(PerformContext context)

You can create multiple progress bars and update them separately.

By default, progress bar is initialized with value `0`. You can specify initial value and progress bar color as optional arguments for `WriteProgressBar()`.
By default, progress bar is initialized with value `0`. You can specify initial value and progress bar color as optional
arguments for `WriteProgressBar()`.

### Enumeration progress

To easily track progress of enumeration over a collection in a for-each loop, library adds an extension method `WithProgress`:
To easily track progress of enumeration over a collection in a for-each loop, library adds an extension
method `WithProgress`:

```c#
public void TaskMethod(PerformContext context)
Expand All @@ -117,13 +128,17 @@ public void TaskMethod(PerformContext context)
}
```

It will automatically update progress bar during enumeration, and will set progress to 100% if for-each loop was interrupted with a `break` instruction.
It will automatically update progress bar during enumeration, and will set progress to 100% if for-each loop was
interrupted with a `break` instruction.

**NOTE**: If the number of items in the collection cannot be determined automatically (e.g. collection doesn't implement `ICollection`/`ICollection<T>`/`IReadOnlyCollection<T>`, you'll need to pass additional argument `count` to the extension method).
**NOTE**: If the number of items in the collection cannot be determined automatically (e.g. collection doesn't
implement `ICollection`/`ICollection<T>`/`IReadOnlyCollection<T>`, you'll need to pass additional argument `count` to
the extension method).

## License

Copyright (c) 2016 Alexey Skalozub
Copyright (c) 2023 IdentityStream AS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
48 changes: 0 additions & 48 deletions appveyor.yml

This file was deleted.

Loading