[1.6.1] ProgrammLogger Fixed
This commit is contained in:
parent
61f26e69af
commit
e3d37988c9
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 1.6.1 - 2022-01-20 - ProgrammLogger Fixed
|
||||||
|
### New Features
|
||||||
|
### Bugfixes
|
||||||
|
* Unhandled exception. System.IO.IOException: The file '/var/log/zwaybot/debug.log' already exists.
|
||||||
|
### Changes
|
||||||
|
|
||||||
## 1.6.0 - 2022-01-09 - HttpEndpoint added
|
## 1.6.0 - 2022-01-09 - HttpEndpoint added
|
||||||
### New Features
|
### New Features
|
||||||
* Add HttpEndpoint
|
* Add HttpEndpoint
|
||||||
|
@ -26,7 +26,7 @@ namespace BlubbFish.Utils {
|
|||||||
Console.Error.WriteLine("Cannot write to " + file);
|
Console.Error.WriteLine("Cannot write to " + file);
|
||||||
throw new ArgumentException("Cannot write to " + file);
|
throw new ArgumentException("Cannot write to " + file);
|
||||||
}
|
}
|
||||||
this.fw = new FileWriter(file);
|
this.fw = new FileWriter(file, false);
|
||||||
this.stdout = new ConsoleWriter(Console.Out, ConsoleWriterEventArgs.ConsoleType.Info);
|
this.stdout = new ConsoleWriter(Console.Out, ConsoleWriterEventArgs.ConsoleType.Info);
|
||||||
this.errout = new ConsoleWriter(Console.Error, ConsoleWriterEventArgs.ConsoleType.Error);
|
this.errout = new ConsoleWriter(Console.Error, ConsoleWriterEventArgs.ConsoleType.Error);
|
||||||
}
|
}
|
||||||
@ -53,15 +53,32 @@ namespace BlubbFish.Utils {
|
|||||||
this.DisattachToFw();
|
this.DisattachToFw();
|
||||||
this.fw.Close();
|
this.fw.Close();
|
||||||
if(new FileInfo(this.loggerfile).Length > 0) {
|
if(new FileInfo(this.loggerfile).Length > 0) {
|
||||||
|
if(File.Exists(file)) {
|
||||||
|
this.FileCopy(this.loggerfile, file);
|
||||||
|
File.Delete(this.loggerfile);
|
||||||
|
} else {
|
||||||
File.Move(this.loggerfile, file);
|
File.Move(this.loggerfile, file);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
File.Delete(this.loggerfile);
|
File.Delete(this.loggerfile);
|
||||||
}
|
}
|
||||||
this.loggerfile = file;
|
this.loggerfile = file;
|
||||||
this.fw = new FileWriter(this.loggerfile);
|
this.fw = new FileWriter(this.loggerfile, true);
|
||||||
this.AttachToFw();
|
this.AttachToFw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FileCopy(String source, String target) {
|
||||||
|
using FileStream fread = new FileStream(source, FileMode.Open);
|
||||||
|
using FileStream fwrite = new FileStream(target, FileMode.Create);
|
||||||
|
using TextReader reader = new StreamReader(fread);
|
||||||
|
using TextWriter writer = new StreamWriter(fwrite);
|
||||||
|
|
||||||
|
writer.Write(reader.ReadToEnd());
|
||||||
|
writer.Flush();
|
||||||
|
writer.Close();
|
||||||
|
reader.Close();
|
||||||
|
}
|
||||||
|
|
||||||
private void DisattachToFw() {
|
private void DisattachToFw() {
|
||||||
this.stdout.WriteEvent -= this.fw.Write;
|
this.stdout.WriteEvent -= this.fw.Write;
|
||||||
this.stdout.WriteLineEvent -= this.fw.WriteLine;
|
this.stdout.WriteLineEvent -= this.fw.WriteLine;
|
||||||
@ -78,7 +95,7 @@ namespace BlubbFish.Utils {
|
|||||||
|
|
||||||
internal class FileWriter : StreamWriter {
|
internal class FileWriter : StreamWriter {
|
||||||
private Boolean newline = true;
|
private Boolean newline = true;
|
||||||
public FileWriter(String path) : base(path) {
|
public FileWriter(String path, Boolean append) : base(path, append) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Encoding Encoding => Encoding.UTF8;
|
public override Encoding Encoding => Encoding.UTF8;
|
||||||
|
@ -8,37 +8,38 @@
|
|||||||
<Company>BlubbFish</Company>
|
<Company>BlubbFish</Company>
|
||||||
<Authors>BlubbFish</Authors>
|
<Authors>BlubbFish</Authors>
|
||||||
<PackageId>Utils.BlubbFish</PackageId>
|
<PackageId>Utils.BlubbFish</PackageId>
|
||||||
<Copyright>Copyright © BlubbFish 2014 - 09.01.2022</Copyright>
|
<Copyright>Copyright © BlubbFish 2014 - 20.01.2022</Copyright>
|
||||||
<Version>1.6.0</Version>
|
<Version>1.6.1</Version>
|
||||||
<NeutralLanguage>de-DE</NeutralLanguage>
|
<NeutralLanguage>de-DE</NeutralLanguage>
|
||||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||||
<PackageProjectUrl>http://git.blubbfish.net/vs_utils/Utils</PackageProjectUrl>
|
<PackageProjectUrl>http://git.blubbfish.net/vs_utils/Utils</PackageProjectUrl>
|
||||||
<RepositoryUrl>http://git.blubbfish.net/vs_utils/Utils.git</RepositoryUrl>
|
<RepositoryUrl>http://git.blubbfish.net/vs_utils/Utils.git</RepositoryUrl>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<PackageReleaseNotes>
|
<PackageReleaseNotes>
|
||||||
1.6.0 HttpEndpoint added
|
1.6.1 - 2022-01-20 - ProgrammLogger Fixed
|
||||||
1.5.0 Add GetEvent so you can call events by string; Add OwnSingeton class
|
1.6.0 - 2022-01-09 - HttpEndpoint added
|
||||||
1.4.0 Add Helper to Utils
|
1.5.0 - 2021-04-10 - Add GetEvent so you can call events by string; Add OwnSingeton class
|
||||||
1.1.3 Improve CmdArgs
|
1.4.0 - 2018-11-27 - Add Helper to Utils
|
||||||
1.1.2 Tiny Codingstyles
|
1.1.3 - 2018-10-02 - Improve CmdArgs
|
||||||
1.1.1 ProgrammLogger neets to cleanup
|
1.1.2 - 2018-09-11 - Tiny Codingstyles
|
||||||
1.1.0 ProgrammLogger
|
1.1.1 - 2018-05-29 - ProgrammLogger neets to cleanup
|
||||||
1.0.7.0 Yet another IniReader improvemnt round again
|
1.1.0 - 2018-05-15 - ProgrammLogger
|
||||||
1.0.6.0 Yet another IniReader improvemnt round
|
1.0.7.0 - 2018-05-08 - Yet another IniReader improvemnt round again
|
||||||
1.0.5.2 And Improve IniReader again
|
1.0.6.0 - 2017-12-22 - Yet another IniReader improvemnt round
|
||||||
1.0.5.1 Improve IniReader again
|
1.0.5.2 - 2017-09-26 - And Improve IniReader again
|
||||||
1.0.5.0 Improve IniReader
|
1.0.5.1 - 2017-09-24 - Improve IniReader again
|
||||||
1.0.4.1 Cleanup OwnView
|
1.0.5.0 - 2017-08-09 - Improve IniReader
|
||||||
1.0.4.0 More Updater
|
1.0.4.1 - 2017-08-08 - Cleanup OwnView
|
||||||
1.0.3.2 Next Updater
|
1.0.4.0 - 2017-04-30 - More Updater
|
||||||
1.0.3.1 EventArgsHelper
|
1.0.3.2 - 2017-04-26 - Next Updater
|
||||||
1.0.2.6 Better Updater
|
1.0.3.1 - 2017-04-25 - EventArgsHelper
|
||||||
1.0.2.5 Logging in OwnObject
|
1.0.2.6 - 2017-04-24 - Better Updater
|
||||||
1.0.2.3 OwnModel better
|
1.0.2.5 - 2017-04-19 - Logging in OwnObject
|
||||||
1.0.2.2 Make it nice
|
1.0.2.3 - 2017-04-16 - OwnModel better
|
||||||
1.0.2.1 Filemutex
|
1.0.2.2 - 2017-03-09 - Make it nice
|
||||||
1.0.0.1 Filelogger improvements
|
1.0.2.1 - 2017-03-09 - Filemutex
|
||||||
1.0.0.0 Init
|
1.0.0.1 - 2016-12-03 - Filelogger improvements
|
||||||
|
1.0.0.0 - 2015-11-16 - Init
|
||||||
</PackageReleaseNotes>
|
</PackageReleaseNotes>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user