BUG-1991: Fixed missing log file for PAF version.

This commit is contained in:
Robin 2016-07-12 21:06:52 +02:00
commit 7d69b6b3bb
7 changed files with 33 additions and 42 deletions

View file

@ -379,7 +379,7 @@
<None Include="Lib\log4net.dll" />
<None Include="log4net-debug.xml" />
<None Include="log4net-portable.xml">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="log4net.xml">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>

View file

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!-- This file can be used to make Greenshot log in the application directory -->
<!-- See http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html -->
<log4net>
<appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
<file value="Data\Greenshot\Greenshot.log" />

View file

@ -17,6 +17,7 @@ Fixed:
* BUG-1890: Slight cropping around window on Windows 10
* BUG-1892: Greenshot saves blank JPG file with reduce colors
* BUG-1898: Specify GPLv3 in the license text
* BUG-1910: Error occurs after adding 10+ text boxes with arrows
* BUG-1918: Speechbubble issue: Artifacts appeared when shadow is on and transparency is used
* BUG-1933: Greenshot Installer sets bad registry key permission
* BUG-1935: Delay when pasting and ShapeShifter from FlameFusion is running
@ -24,20 +25,17 @@ Fixed:
* BUG-1945: Failure starting Greenshot at system startup
* BUG-1949: Can't delete Imgur upload
* BUG-1965: Activation border around window is visible in the capture
* FEATURE-916: Added icon as possible format to save with (image is sized to 256x256)
* FEATURE-919: Allow adding of space around screenshot
* FEATURE-945:Added environment variables resolving to the external command
* BUG-1991: Greenshot portable (PAF) uses wrong log configuration
* FEATURE-916: Added ico file format
* FEATURE-919: Allow adding of space around screenshot (use Ctrl + / Ctrl -)
* FEATURE-945: Added environment variables resolving to the external command
* FEATURE-949: Updated to Inno-Setup 5.5.9 for improved installer security
Open issues planned for this version:
BUG-1872: OneDrive prevents Greenshot hotkeys from working
BUG-1908: External Command plugin should check for possible default-commands at startup
BUG-1910: Error occurs after adding 10+ text boxes with arrows
FEATURE-912: [Storage Location] Define directory pattern
Known issues:
* TextContainer (the thing in the editor that can add text to your capture) can throw exceptions.
1.2.8.12-cab854b RELEASE

View file

@ -61,7 +61,7 @@ namespace GreenshotPlugin.Core {
LOG.Warn("IniConfig hasn't been initialized yet! (Design mode?)");
IniConfig.Init("greenshot", "greenshot");
}
if (!LogHelper.isInitialized) {
if (!LogHelper.IsInitialized) {
LOG.Warn("Log4net hasn't been initialized yet! (Design mode?)");
LogHelper.InitializeLog4NET();
}

View file

@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.IO;
using System.Reflection;
using System.Windows.Forms;
@ -32,47 +33,44 @@ using log4net.Util;
namespace GreenshotPlugin.Core {
/// <summary>
/// Description of LogHelper.
/// Initialize the logger
/// </summary>
public class LogHelper {
private const string LOG4NET_FILE = "log4net.xml";
private const string LOG4NET_PORTABLE_FILE = "log4net-portable.xml";
private static bool isLog4NetConfigured;
private static bool _isLog4NetConfigured;
private const string INIT_MESSAGE = "Greenshot initialization of log system failed";
public static bool isInitialized {
public static bool IsInitialized {
get {
return isLog4NetConfigured;
return _isLog4NetConfigured;
}
}
// Initialize Log4J
public static string InitializeLog4NET() {
// Setup log4j, currently the file is called log4net.xml
string pafLog4NetFilename = Path.Combine(Application.StartupPath, @"App\Greenshot\" + LOG4NET_PORTABLE_FILE);
string log4netFilename = Path.Combine(Application.StartupPath, LOG4NET_FILE);
if (File.Exists(log4netFilename)) {
try {
XmlConfigurator.Configure(new FileInfo(log4netFilename));
isLog4NetConfigured = true;
} catch (Exception ex) {
MessageBox.Show(ex.Message, INIT_MESSAGE, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
} else if (File.Exists(pafLog4NetFilename)) {
try {
XmlConfigurator.Configure(new FileInfo(pafLog4NetFilename));
isLog4NetConfigured = true;
} catch (Exception ex) {
MessageBox.Show(ex.Message, INIT_MESSAGE, MessageBoxButtons.OK, MessageBoxIcon.Warning);
foreach (var logName in new[] { "log4net.xml" , @"App\Greenshot\log4net-portable.xml"})
{
string log4NetFilename = Path.Combine(Application.StartupPath, logName);
if (File.Exists(log4NetFilename))
{
try
{
XmlConfigurator.Configure(new FileInfo(log4NetFilename));
_isLog4NetConfigured = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, INIT_MESSAGE, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
if (!isLog4NetConfigured) {
// Fallback
if (!_isLog4NetConfigured) {
try {
Assembly assembly = typeof(LogHelper).Assembly;
using (Stream stream = assembly.GetManifestResourceStream("GreenshotPlugin.log4net-embedded.xml")) {
XmlConfigurator.Configure(stream);
isLog4NetConfigured = true;
_isLog4NetConfigured = true;
IniConfig.ForceIniInStartupPath();
}
} catch (Exception ex){
@ -80,7 +78,7 @@ namespace GreenshotPlugin.Core {
}
}
if (isLog4NetConfigured) {
if (_isLog4NetConfigured) {
// Get the logfile name
try {
if (((Hierarchy)LogManager.GetRepository()).Root.Appenders.Count > 0) {
@ -100,7 +98,7 @@ namespace GreenshotPlugin.Core {
/// A simple helper class to support the logging to the AppData location
/// </summary>
public class SpecialFolderPatternConverter : PatternConverter {
override protected void Convert(TextWriter writer, object state) {
protected override void Convert(TextWriter writer, object state) {
Environment.SpecialFolder specialFolder = (Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), Option, true);
writer.Write(Environment.GetFolderPath(specialFolder));
}

View file

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!-- This file can be used to make Greenshot log in the application directory -->
<!-- See http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html -->
<log4net>
<appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
<file value="Greenshot.log" />

View file

@ -104,7 +104,7 @@ Function PackagePortable {
"$sourcebase\Greenshot.exe.config",
"$sourcebase\GreenshotPlugin.dll",
"$sourcebase\log4net.dll",
"$sourcebase\log4net.xml",
"$sourcebase\log4net-portable.xml",
"$destbase\additional_files\*.txt" ) | foreach { Copy-Item $_ "$destbase\portabletmp\App\Greenshot\" }
Copy-Item -Path "$sourcebase\Languages\help-en-US.html" -Destination "$destbase\portabletmp\help.html"
@ -170,7 +170,6 @@ Function PackageZip {
"$sourcebase\Greenshot.exe.config",
"$sourcebase\GreenshotPlugin.dll",
"$sourcebase\log4net.dll",
"$sourcebase\log4net.xml",
"$destbase\additional_files\*.txt" ) | foreach { Copy-Item $_ "$destzip\" }
$zipOutput = "$(get-location)\zip"