Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
LcdLogger
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Antoni Zaprzała
LcdLogger
Commits
42775126
Commit
42775126
authored
Jun 30, 2026
by
Antoni Zaprzała
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small changes
parent
8187443f
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
15 additions
and
22 deletions
+15
-22
LcdLogger.http
LcdLogger/LcdLogger.http
+0
-6
LogEntry.cs
LcdLogger/Models/LogEntry.cs
+1
-3
LogOptions.cs
LcdLogger/Models/LogOptions.cs
+0
-1
Program.cs
LcdLogger/Program.cs
+2
-3
launchSettings.json
LcdLogger/Properties/launchSettings.json
+2
-2
LogFileManager.cs
LcdLogger/Services/LogFileManager.cs
+9
-5
LogWorker.cs
LcdLogger/Services/LogWorker.cs
+1
-1
appsettings.json
LcdLogger/appsettings.json
+0
-1
No files found.
LcdLogger/LcdLogger.http
deleted
100644 → 0
View file @
8187443f
@LcdLogger_HostAddress = http://localhost:5194
GET {{LcdLogger_HostAddress}}/weatherforecast/
Accept: application/json
###
LcdLogger/Models/LogEntry.cs
View file @
42775126
...
@@ -6,13 +6,11 @@ namespace LcdLogger.Models
...
@@ -6,13 +6,11 @@ namespace LcdLogger.Models
public
sealed
class
LogEntry
public
sealed
class
LogEntry
{
{
[
JsonPropertyName
(
"timestamp"
)]
[
JsonPropertyName
(
"timestamp"
)]
public
long
TimeStamp
{
get
;
set
;
}
public
string
TimeStamp
{
get
;
set
;
}
=
""
;
//log level
[
JsonPropertyName
(
"level"
)]
[
JsonPropertyName
(
"level"
)]
public
int
Level
{
get
;
set
;
}
public
int
Level
{
get
;
set
;
}
//service name/ component name that logged
[
JsonPropertyName
(
"source"
)]
[
JsonPropertyName
(
"source"
)]
public
string
Source
{
get
;
set
;
}
=
""
;
public
string
Source
{
get
;
set
;
}
=
""
;
...
...
LcdLogger/Models/LogOptions.cs
View file @
42775126
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
public
long
RotateAtBytes
{
get
;
set
;
}
=
20971520
;
public
long
RotateAtBytes
{
get
;
set
;
}
=
20971520
;
public
long
MaxTotalBytes
{
get
;
set
;
}
=
104857600
;
public
long
MaxTotalBytes
{
get
;
set
;
}
=
104857600
;
public
int
MinLevel
{
get
;
set
;
}
=
2
;
public
int
MinLevel
{
get
;
set
;
}
=
2
;
public
int
FlushEveryMs
{
get
;
set
;
}
=
500
;
public
int
MaxBatchEntries
{
get
;
set
;
}
=
100
;
public
int
MaxBatchEntries
{
get
;
set
;
}
=
100
;
public
int
QueueCapacity
{
get
;
set
;
}
=
250
;
public
int
QueueCapacity
{
get
;
set
;
}
=
250
;
...
...
LcdLogger/Program.cs
View file @
42775126
...
@@ -10,9 +10,8 @@ builder.Services.AddHostedService<LogWorker>();
...
@@ -10,9 +10,8 @@ builder.Services.AddHostedService<LogWorker>();
var
app
=
builder
.
Build
();
var
app
=
builder
.
Build
();
//sprawdzenie uzywanych appsettingsow przez serwis - moze useless i wywalic idk
//app.MapGet("/debug/options", (IOptions<LogOptions> options) =>
app
.
MapGet
(
"/debug/options"
,
(
IOptions
<
LogOptions
>
options
)
=>
// Results.Ok(options.Value));
Results
.
Ok
(
options
.
Value
));
app
.
MapPost
(
"/logs"
,
(
LogBatch
batch
,
LogQueue
queue
,
IOptions
<
LogOptions
>
opts
)
=>
app
.
MapPost
(
"/logs"
,
(
LogBatch
batch
,
LogQueue
queue
,
IOptions
<
LogOptions
>
opts
)
=>
...
...
LcdLogger/Properties/launchSettings.json
View file @
42775126
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
"launchBrowser"
:
false
,
"launchBrowser"
:
false
,
"applicationUrl"
:
"http://localhost:5194"
,
"applicationUrl"
:
"http://localhost:5194"
,
"environmentVariables"
:
{
"environmentVariables"
:
{
"ASPNETCORE_ENVIRONMENT"
:
"Development"
}
}
},
},
"https"
:
{
"https"
:
{
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
"launchBrowser"
:
false
,
"launchBrowser"
:
false
,
"applicationUrl"
:
"https://localhost:7291;http://localhost:5194"
,
"applicationUrl"
:
"https://localhost:7291;http://localhost:5194"
,
"environmentVariables"
:
{
"environmentVariables"
:
{
"ASPNETCORE_ENVIRONMENT"
:
"Development"
}
}
}
}
}
}
...
...
LcdLogger/Services/LogFileManager.cs
View file @
42775126
...
@@ -25,14 +25,14 @@ namespace LcdLogger.Services
...
@@ -25,14 +25,14 @@ namespace LcdLogger.Services
{
{
Directory
.
CreateDirectory
(
_options
.
Directory
);
Directory
.
CreateDirectory
(
_options
.
Directory
);
await
Prune
Old
FilesAsync
(
cancellationToken
);
await
Prune
Surplus
FilesAsync
(
cancellationToken
);
await
OpenNewAsync
(
cancellationToken
);
await
OpenNewAsync
(
cancellationToken
);
}
}
private
Task
OpenNewAsync
(
CancellationToken
cancellationToken
=
default
)
private
Task
OpenNewAsync
(
CancellationToken
cancellationToken
=
default
)
{
{
var
timestamp
=
DateTime
.
UtcNow
.
ToString
(
"yyyyMMddTHHmmssfffZ
"
);
var
timestamp
=
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd_HH-mm-ss
"
);
_currentPath
=
Path
.
Combine
(
_options
.
Directory
,
$"lcd-
{
timestamp
}
.log"
);
_currentPath
=
Path
.
Combine
(
_options
.
Directory
,
$"lcd-
{
timestamp
}
.log"
);
_fileStream
=
new
FileStream
(
_currentPath
,
FileMode
.
CreateNew
,
FileAccess
.
Write
,
FileShare
.
Read
,
bufferSize
:
1
,
useAsync
:
true
);
_fileStream
=
new
FileStream
(
_currentPath
,
FileMode
.
CreateNew
,
FileAccess
.
Write
,
FileShare
.
Read
,
bufferSize
:
1
,
useAsync
:
true
);
_size
=
0
;
_size
=
0
;
...
@@ -46,7 +46,11 @@ namespace LcdLogger.Services
...
@@ -46,7 +46,11 @@ namespace LcdLogger.Services
{
{
if
(
entry
.
Level
<
_options
.
MinLevel
)
continue
;
if
(
entry
.
Level
<
_options
.
MinLevel
)
continue
;
var
bytes
=
JsonSerializer
.
SerializeToUtf8Bytes
(
entry
);
//var bytes = JsonSerializer.SerializeToUtf8Bytes(entry);
var
bytes
=
JsonSerializer
.
SerializeToUtf8Bytes
(
entry
,
new
JsonSerializerOptions
{
Encoder
=
System
.
Text
.
Encodings
.
Web
.
JavaScriptEncoder
.
UnsafeRelaxedJsonEscaping
});
await
_fileStream
.
WriteAsync
(
bytes
,
cancellationToken
);
await
_fileStream
.
WriteAsync
(
bytes
,
cancellationToken
);
await
_fileStream
.
WriteAsync
(
_newline
,
cancellationToken
);
await
_fileStream
.
WriteAsync
(
_newline
,
cancellationToken
);
...
@@ -60,7 +64,7 @@ namespace LcdLogger.Services
...
@@ -60,7 +64,7 @@ namespace LcdLogger.Services
}
}
}
}
private
Task
Prune
Old
FilesAsync
(
CancellationToken
cancellationToken
=
default
)
private
Task
Prune
Surplus
FilesAsync
(
CancellationToken
cancellationToken
=
default
)
{
{
var
DirectoryInfo
=
new
DirectoryInfo
(
_options
.
Directory
);
var
DirectoryInfo
=
new
DirectoryInfo
(
_options
.
Directory
);
if
(!
DirectoryInfo
.
Exists
)
if
(!
DirectoryInfo
.
Exists
)
...
@@ -109,7 +113,7 @@ namespace LcdLogger.Services
...
@@ -109,7 +113,7 @@ namespace LcdLogger.Services
await
CompressAsync
(
justClosedFile
);
await
CompressAsync
(
justClosedFile
);
});
});
await
Prune
Old
FilesAsync
(
cancellationToken
);
await
Prune
Surplus
FilesAsync
(
cancellationToken
);
await
OpenNewAsync
(
cancellationToken
);
await
OpenNewAsync
(
cancellationToken
);
}
}
...
...
LcdLogger/Services/LogWorker.cs
View file @
42775126
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
_logger
.
LogError
(
e
,
"Failed to write batch with {Count} entries"
,
batch
.
Logs
.
Length
);
_logger
.
LogError
(
"Failed to write batch {e}"
,
e
);
}
}
}
}
}
}
...
...
LcdLogger/appsettings.json
View file @
42775126
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
"RotateAtBytes"
:
20971520
,
"RotateAtBytes"
:
20971520
,
"MaxTotalBytes"
:
104857600
,
"MaxTotalBytes"
:
104857600
,
"MinLevel"
:
2
,
"MinLevel"
:
2
,
"FlushEveryMs"
:
500
,
"MaxBatchEntries"
:
100
,
"MaxBatchEntries"
:
100
,
"QueueCapacity"
:
250
"QueueCapacity"
:
250
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment