Skip to content

Commit

Permalink
kontalog does not flush on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
DBJDBJ committed Mar 28, 2024
1 parent 0e21d44 commit da93e05
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
3 changes: 3 additions & 0 deletions sampling/kontalog_sample/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"LOOP_LENGTH" : 10
}
19 changes: 7 additions & 12 deletions sampling/kontalog_sample/dbj_kontalog_sample.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
#define stress_test

using dbjcore;
using Log = dbjcore.Kontalog;
using Utl = dbjcore.DBJcore;

Log.info("Running on: " + Utl.my_domain(false));
Log.info("Program: " + Utl.my_domain() + ", purpose: KONTALOG logging sample!");

#if stress_test
Log.info( " This KONTALOG stress test will attempt to run forever.");
var LOOP_LENGTH = DBJCfg.get<int>("LOOP_LENGTH", 0);
Log.info("LOOP_LENGTH is defined in " + DBJCfg.instance.config_file_name + " as: " + LOOP_LENGTH);


long counter = 0L;
while (true)
while (counter != LOOP_LENGTH)
{
counter = 1 + (counter % long.MaxValue);
counter = 1 + (counter % LOOP_LENGTH);
// Kontalog in prod only fatal will be shown
Log.fatal("Counter: {0,12} !", counter);
}
#else
for (System.Int32 k = 0; k < 0xF; ++k)
Log.debug("Hello, {0,12} !", k);
Log.fatal("Loop (size = {0}) done.", 0xF);

Log.info("Done. Press ENTER");
Console.ReadLine();
#endif

Log.info("Done");
// WARNING! Console.Writeline will be out of sync, if used
7 changes: 7 additions & 0 deletions sampling/kontalog_sample/kontalog_sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,11 @@
<ProjectReference Include="..\..\dbjcore.csproj" />
</ItemGroup>

<!-- Required for the configurator to work -->
<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Project>
6 changes: 4 additions & 2 deletions src/config/dbj_core_config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ followed with section that adds the dot net components to use from the code
public sealed class DBJCfg
{
IConfiguration config;
readonly string config_file_name = string.Empty;
public readonly string config_file_name = string.Empty;


/*
config file name is completely 100% arbitrary
it is hidden as def. val constructor parameter
I know that is not a good thing, but I am lazy , and besides that
How to configure the congiguration? Externaly? Probably using the cli arguments?
How to configure the configuration? Externaly? Probably using the cli arguments?
*/
public DBJCfg(string json_config_file = "appsettings.json")
{
Expand Down
1 change: 1 addition & 0 deletions src/config/dbj_core_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ config specimen used bellow:
```
Usage is simple. There is basically one static method on the `DBJCfg` class.
```c#

// example using the config file above
var max_block_count = DBJCfg.get<short>("max_block_count", 0 );
```
Expand Down
4 changes: 2 additions & 2 deletions src/kontalog/dbj_core_kontalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ static Kontalog()

// Slow down consumer just a little to cause
// collection to fill up faster, and lead to "AddBlocked"
const int spin_wait = 0xFFFFF;
Thread.SpinWait(spin_wait);
//const int spin_wait = 0xFFFFF;
//Thread.SpinWait(spin_wait);
}
});
thread.IsBackground = true;
Expand Down

0 comments on commit da93e05

Please sign in to comment.