Changeset 100 for ExceptionLogger


Ignore:
Timestamp:
Dec 21, 2010, 9:27:01 AM (14 years ago)
Author:
george
Message:
  • Added: Logging application version readed from exe file meta information.
Location:
ExceptionLogger
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ExceptionLogger/UExceptionLogger.pas

    r40 r100  
    66
    77uses
     8  {$ifdef windows}Windows,{$endif}
    89  Classes, SysUtils, UStackTrace, CustomLineInfo, Forms;
    910
     
    1617    FMaxCallStackDepth: Integer;
    1718    FLogFileName: string;
     19    function GetAppVersion: string;
    1820    procedure MakeReport;
    1921    procedure SetMaxCallStackDepth(const AValue: Integer);
     
    4951  SProcessID = 'Process ID';
    5052  SThreadID = 'Thread ID';
     53  SVersion = 'Version';
    5154
    5255procedure Register;
     
    8184    Add(SMessage + ': ' + LastException.Message);
    8285    Add(SApplication + ': ' + Application.Title);
     86    Add(SVersion + ': ' + GetAppVersion);
    8387    Add(STime + ': ' + DateTimeToStr(Now));
    8488    Add(SProcessID + ': ' + IntToStr(GetProcessID));
     
    119123    with TStackFrameInfo(StackTrace[I]) do begin
    120124      Line := IntToStr(Index) + ': ' + IntToHex(Address, 8) + ' in ' + FunctionName + ' ' +
    121         Source + '(' + IntToStr(LineNumber) + ')' + #13#10;
     125        Source + '(' + IntToStr(LineNumber) + ')' + LineEnding;
    122126      if Length(Line) > 0 then
    123127        Write(Line[1], Length(Line));
    124128    end;
    125     Line := #13#10;
     129    Line := LineEnding;
    126130    Write(Line[1], Length(Line));
    127131  finally
     
    181185end;
    182186
     187function TExceptionLogger.GetAppVersion: string;
     188var
     189  Size, Size2: DWord;
     190  Pt, Pt2: Pointer;
     191begin
     192  {$ifdef windows}
     193  Size := GetFileVersionInfoSize(PChar(ParamStr(0)), Size2);
     194  if Size > 0 then
     195  begin
     196    GetMem(Pt, Size);
     197    try
     198       GetFileVersionInfo(PChar (ParamStr(0)), 0, Size, Pt);
     199       VerQueryValue(Pt, '\', Pt2, Size2);
     200       with TVSFixedFileInfo(Pt2^) do
     201       begin
     202         Result := IntToStr(HiWord(dwFileVersionMS)) + '.' +
     203           IntToStr(LoWord(dwFileVersionMS)) + '.' +
     204           IntToStr(HiWord(dwFileVersionLS)) + '.' +
     205           IntToStr(LoWord(dwFileVersionLS));
     206      end;
     207    finally
     208      FreeMem(Pt);
     209    end;
     210  end;
     211  {$else}
     212  Result := '';
     213  {$endif}
     214end;
     215
    183216end.
    184217
  • ExceptionLogger/languages/UExceptionLogger.cs.po

    r39 r100  
    3434msgstr "Čas"
    3535
     36#: uexceptionlogger.sversion
     37msgid "Version"
     38msgstr ""
     39
  • ExceptionLogger/languages/UExceptionLogger.po

    r39 r100  
    2626msgstr ""
    2727
     28#: uexceptionlogger.sversion
     29msgid "Version"
     30msgstr ""
     31
Note: See TracChangeset for help on using the changeset viewer.