1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
|
{
*****************************************************************************
This file is part of LazUtils.
See the file COPYING.modifiedLGPL.txt, included in this distribution,
for details about the license.
*****************************************************************************
}
unit LazLoggerDummy;
{$mode objfpc}{$H+}
(*
Provide an empty re-implementation of LazLoggerBase
The aim is to allow
- RegisterLogGroup
- debugln
to be called, and translate into empty method, or even inline no code at all
Any function above that may be limited
*)
interface
uses
Classes, SysUtils, FileUtil, types, LazClasses;
type
TLazLoggerLogGroupFlag =
( lgfAddedByParamParser, // Not added via Register. This is a placeholder for the enabled-state given by the user, via cmd-line
lgfNoDefaultEnabledSpecified // Registered without default
);
TLazLoggerLogGroupFlags = set of TLazLoggerLogGroupFlag;
TLazLoggerLogGroup = record
ConfigName: String; // case insensitive
Enabled: Boolean;
Flags: TLazLoggerLogGroupFlags;
FOpenedIndents: Integer;
end;
PLazLoggerLogGroup = ^TLazLoggerLogGroup;
TLazLoggerWriteEvent = procedure (Sender: TObject; S: string; var Handled: Boolean) of object;
{$DEFINE USED_BY_LAZLOGGER_DUMMY}
{$push}
{$HINTS off}
{$I LazLoggerIntf.inc}
{$pop}
type
(* All empty methods *)
{ TLazLoggerBlockHandler
called for DebuglnEnter / Exit
}
TLazLoggerBlockHandler = class
public
procedure IncreaseIndent; virtual; abstract;
procedure DecreaseIndent; virtual; abstract;
end;
{ TLazLoggerLogGroupList }
TLazLoggerLogGroupList = class(TRefCountedObject)
private
function GetItem({%H-}Index: Integer): PLazLoggerLogGroup;
public
procedure Assign({%H-}Src: TLazLoggerLogGroupList);
function IndexOf(const {%H-}AConfigName: String): integer;
function IndexOf(const {%H-}AnEntry: PLazLoggerLogGroup): integer;
function Find(const {%H-}AConfigName: String): PLazLoggerLogGroup;
function Count: integer;
property Item[Index: Integer]: PLazLoggerLogGroup read GetItem; default;
end;
{ TLazLogger }
TLazLogger = class(TRefCountedObject)
private
FMaxNestPrefixLen: Integer;
FNestLvlIndent: Integer;
FUseGlobalLogGroupList: Boolean;
function GetLogGroupList: TLazLoggerLogGroupList;
procedure SetMaxNestPrefixLen(AValue: Integer);
procedure SetNestLvlIndent(AValue: Integer);
procedure SetUseGlobalLogGroupList(AValue: Boolean);
public
procedure Assign({%H-}Src: TLazLogger); virtual;
procedure Init;
procedure Finish;
property NestLvlIndent: Integer read FNestLvlIndent write SetNestLvlIndent;
property MaxNestPrefixLen: Integer read FMaxNestPrefixLen write SetMaxNestPrefixLen;
public
function RegisterLogGroup(const {%H-}AConfigName: String; {%H-}ADefaulEnabled: Boolean) : PLazLoggerLogGroup; virtual;
function RegisterLogGroup(const {%H-}AConfigName: String) : PLazLoggerLogGroup; virtual;
function FindOrRegisterLogGroup(const {%H-}AConfigName: String; {%H-}ADefaulEnabled: Boolean) : PLazLoggerLogGroup; virtual;
function FindOrRegisterLogGroup(const {%H-}AConfigName: String) : PLazLoggerLogGroup; virtual;
property LogGroupList: TLazLoggerLogGroupList read GetLogGroupList;
property UseGlobalLogGroupList: Boolean read FUseGlobalLogGroupList write SetUseGlobalLogGroupList;
public
procedure DebuglnStack(const {%H-}s: string = '');
procedure DbgOut(const {%H-}s: string = ''); overload;
procedure DbgOut({%H-}Args: array of const); overload;
procedure DbgOut(const {%H-}S: String; {%H-}Args: array of const); overload;// similar to Format(s,Args)
procedure DbgOut(const {%H-}s1, {%H-}s2: string; const {%H-}s3: string = '';
const {%H-}s4: string = ''; const {%H-}s5: string = ''; const {%H-}s6: string = '';
const {%H-}s7: string = ''; const {%H-}s8: string = ''; const {%H-}s9: string = '';
const {%H-}s10: string = ''; const {%H-}s11: string = ''; const {%H-}s12: string = '';
const {%H-}s13: string = ''; const {%H-}s14: string = ''; const {%H-}s15: string = '';
const {%H-}s16: string = ''; const {%H-}s17: string = ''; const {%H-}s18: string = ''); overload;
procedure DebugLn(const {%H-}s: string = ''); overload;
procedure DebugLn({%H-}Args: array of const); overload;
procedure DebugLn(const {%H-}S: String; {%H-}Args: array of const); overload;// similar to Format(s,Args)
procedure DebugLn(const {%H-}s1, {%H-}s2: string; const {%H-}s3: string = '';
const {%H-}s4: string = ''; const {%H-}s5: string = ''; const {%H-}s6: string = '';
const {%H-}s7: string = ''; const {%H-}s8: string = ''; const {%H-}s9: string = '';
const {%H-}s10: string = ''; const {%H-}s11: string = ''; const {%H-}s12: string = '';
const {%H-}s13: string = ''; const {%H-}s14: string = ''; const {%H-}s15: string = '';
const {%H-}s16: string = ''; const {%H-}s17: string = ''; const {%H-}s18: string = ''); overload;
procedure DebugLnEnter(const {%H-}s: string = ''); overload;
procedure DebugLnEnter({%H-}Args: array of const); overload;
procedure DebugLnEnter({%H-}s: string; {%H-}Args: array of const); overload;
procedure DebugLnEnter(const {%H-}s1, {%H-}s2: string; const {%H-}s3: string = '';
const {%H-}s4: string = ''; const {%H-}s5: string = ''; const {%H-}s6: string = '';
const {%H-}s7: string = ''; const {%H-}s8: string = ''; const {%H-}s9: string = '';
const {%H-}s10: string = ''; const {%H-}s11: string = ''; const {%H-}s12: string = '';
const {%H-}s13: string = ''; const {%H-}s14: string = ''; const {%H-}s15: string = '';
const {%H-}s16: string = ''; const {%H-}s17: string = ''; const {%H-}s18: string = ''); overload;
procedure DebugLnExit(const {%H-}s: string = ''); overload;
procedure DebugLnExit({%H-}Args: array of const); overload;
procedure DebugLnExit({%H-}s: string; {%H-}Args: array of const); overload;
procedure DebugLnExit(const {%H-}s1, {%H-}s2: string; const {%H-}s3: string = '';
const {%H-}s4: string = ''; const {%H-}s5: string = ''; const {%H-}s6: string = '';
const {%H-}s7: string = ''; const {%H-}s8: string = ''; const {%H-}s9: string = '';
const {%H-}s10: string = ''; const {%H-}s11: string = ''; const {%H-}s12: string = '';
const {%H-}s13: string = ''; const {%H-}s14: string = ''; const {%H-}s15: string = '';
const {%H-}s16: string = ''; const {%H-}s17: string = ''; const {%H-}s18: string = ''); overload;
procedure DebuglnStack({%H-}LogGroup: PLazLoggerLogGroup; const {%H-}s: string = '');
procedure DbgOut({%H-}LogGroup: PLazLoggerLogGroup; const {%H-}s: string = ''); overload;
procedure DbgOut({%H-}LogGroup: PLazLoggerLogGroup; {%H-}Args: array of const); overload;
procedure DbgOut({%H-}LogGroup: PLazLoggerLogGroup; const {%H-}S: String; {%H-}Args: array of const); overload;// similar to Format(s,Args)
procedure DbgOut({%H-}LogGroup: PLazLoggerLogGroup; const {%H-}s1, {%H-}s2: string; const {%H-}s3: string = '';
const {%H-}s4: string = ''; const {%H-}s5: string = ''; const {%H-}s6: string = '';
const {%H-}s7: string = ''; const {%H-}s8: string = ''; const {%H-}s9: string = '';
const {%H-}s10: string = ''; const {%H-}s11: string = ''; const {%H-}s12: string = '';
const {%H-}s13: string = ''; const {%H-}s14: string = ''; const {%H-}s15: string = '';
const {%H-}s16: string = ''; const {%H-}s17: string = ''; const {%H-}s18: string = ''); overload;
procedure DebugLn({%H-}LogGroup: PLazLoggerLogGroup; const {%H-}s: string = ''); overload;
procedure DebugLn({%H-}LogGroup: PLazLoggerLogGroup; {%H-}Args: array of const); overload;
procedure DebugLn({%H-}LogGroup: PLazLoggerLogGroup; const {%H-}S: String; {%H-}Args: array of const); overload;// similar to Format(s,Args)
procedure DebugLn({%H-}LogGroup: PLazLoggerLogGroup; const {%H-}s1, {%H-}s2: string; const {%H-}s3: string = '';
const {%H-}s4: string = ''; const {%H-}s5: string = ''; const {%H-}s6: string = '';
const {%H-}s7: string = ''; const {%H-}s8: string = ''; const {%H-}s9: string = '';
const {%H-}s10: string = ''; const {%H-}s11: string = ''; const {%H-}s12: string = '';
const {%H-}s13: string = ''; const {%H-}s14: string = ''; const {%H-}s15: string = '';
const {%H-}s16: string = ''; const {%H-}s17: string = ''; const {%H-}s18: string = ''); overload;
procedure DebugLnEnter({%H-}LogGroup: PLazLoggerLogGroup; const {%H-}s: string = ''); overload;
procedure DebugLnEnter({%H-}LogGroup: PLazLoggerLogGroup; {%H-}Args: array of const); overload;
procedure DebugLnEnter({%H-}LogGroup: PLazLoggerLogGroup; {%H-}s: string; {%H-}Args: array of const); overload;
procedure DebugLnEnter({%H-}LogGroup: PLazLoggerLogGroup; const {%H-}s1, {%H-}s2: string; const {%H-}s3: string = '';
const {%H-}s4: string = ''; const {%H-}s5: string = ''; const {%H-}s6: string = '';
const {%H-}s7: string = ''; const {%H-}s8: string = ''; const {%H-}s9: string = '';
const {%H-}s10: string = ''; const {%H-}s11: string = ''; const {%H-}s12: string = '';
const {%H-}s13: string = ''; const {%H-}s14: string = ''; const {%H-}s15: string = '';
const {%H-}s16: string = ''; const {%H-}s17: string = ''; const {%H-}s18: string = ''); overload;
procedure DebugLnExit({%H-}LogGroup: PLazLoggerLogGroup; const {%H-}s: string = ''); overload;
procedure DebugLnExit({%H-}LogGroup: PLazLoggerLogGroup; {%H-}Args: array of const); overload;
procedure DebugLnExit({%H-}LogGroup: PLazLoggerLogGroup; {%H-}s: string; {%H-}Args: array of const); overload;
procedure DebugLnExit({%H-}LogGroup: PLazLoggerLogGroup; const {%H-}s1, {%H-}s2: string; const {%H-}s3: string = '';
const {%H-}s4: string = ''; const {%H-}s5: string = ''; const {%H-}s6: string = '';
const {%H-}s7: string = ''; const {%H-}s8: string = ''; const {%H-}s9: string = '';
const {%H-}s10: string = ''; const {%H-}s11: string = ''; const {%H-}s12: string = '';
const {%H-}s13: string = ''; const {%H-}s14: string = ''; const {%H-}s15: string = '';
const {%H-}s16: string = ''; const {%H-}s17: string = ''; const {%H-}s18: string = ''); overload;
end;
function GetDebugLoggerGroups: TLazLoggerLogGroupList; inline;
procedure SetDebugLoggerGroups({%H-}ALogGroups: TLazLoggerLogGroupList);
function GetDebugLogger: TLazLogger; inline;
function GetExistingDebugLogger: TLazLogger; inline; // No Autocreate
procedure SetDebugLogger({%H-}ALogger: TLazLogger);
procedure RecreateDebugLogger;
property DebugLogger: TLazLogger read GetDebugLogger write SetDebugLogger;
property DebugLoggerGroups: TLazLoggerLogGroupList read GetDebugLoggerGroups write SetDebugLoggerGroups;
type
TLazDebugLoggerCreator = function: TRefCountedObject;
// Using base TRefCountedObject, so if none of the functions is used in the app, then even the class should be smart linked
var
LazDebugLoggerCreator: TLazDebugLoggerCreator = nil;
OnWidgetSetDebugLn: TLazLoggerWriteEvent;
OnWidgetSetDbgOut: TLazLoggerWriteEvent;
implementation
var // Using base TRefCountedObject, so if none of the functions is used in the app, then even the class should be smart linked
TheLazLogger: TRefCountedObject = nil;
TheLazLoggerGroups: TRefCountedObject = nil;
{$push}
{$HINTS off}
{$I LazLoggerImpl.inc}
{$pop}
procedure CreateDebugLogger;
begin
if (TheLazLogger <> nil) then
exit;
if (TheLazLogger = nil) then
TheLazLogger := TLazLogger.Create;
TheLazLogger.AddReference;
end;
function GetDebugLogger: TLazLogger;
begin
if (TheLazLogger = nil) then
CreateDebugLogger;
Result := TLazLogger(TheLazLogger);
end;
function GetExistingDebugLogger: TLazLogger;
begin
Result := TLazLogger(TheLazLogger);
end;
procedure SetDebugLogger(ALogger: TLazLogger);
begin
end;
procedure RecreateDebugLogger;
begin
end;
function GetDebugLoggerGroups: TLazLoggerLogGroupList;
begin
if (TheLazLoggerGroups = nil) then begin
TheLazLoggerGroups := TLazLoggerLogGroupList.Create;
TheLazLoggerGroups.AddReference;
end;
Result := TLazLoggerLogGroupList(TheLazLoggerGroups);
end;
procedure SetDebugLoggerGroups(ALogGroups: TLazLoggerLogGroupList);
begin
end;
function TLazLogger.GetLogGroupList: TLazLoggerLogGroupList;
begin
Result := DebugLoggerGroups;
end;
procedure TLazLogger.SetMaxNestPrefixLen(AValue: Integer);
begin
FMaxNestPrefixLen := AValue;
end;
procedure TLazLogger.SetNestLvlIndent(AValue: Integer);
begin
FNestLvlIndent := AValue;
end;
procedure TLazLogger.SetUseGlobalLogGroupList(AValue: Boolean);
begin
FUseGlobalLogGroupList := AValue;
end;
procedure TLazLogger.Assign(Src: TLazLogger);
begin
end;
procedure TLazLogger.Init;
begin
end;
procedure TLazLogger.Finish;
begin
end;
function TLazLogger.RegisterLogGroup(const AConfigName: String;
ADefaulEnabled: Boolean): PLazLoggerLogGroup;
begin
Result := nil;
end;
function TLazLogger.RegisterLogGroup(const AConfigName: String): PLazLoggerLogGroup;
begin
Result := nil;
end;
function TLazLogger.FindOrRegisterLogGroup(const AConfigName: String;
ADefaulEnabled: Boolean): PLazLoggerLogGroup;
begin
Result := nil;
end;
function TLazLogger.FindOrRegisterLogGroup(const AConfigName: String): PLazLoggerLogGroup;
begin
Result := nil;
end;
procedure TLazLogger.DebuglnStack(const s: string);
begin
end;
procedure TLazLogger.DbgOut(const s: string);
begin
end;
procedure TLazLogger.DbgOut(Args: array of const);
begin
end;
procedure TLazLogger.DbgOut(const S: String; Args: array of const);
begin
end;
procedure TLazLogger.DbgOut(const s1, s2: string; const s3: string; const s4: string;
const s5: string; const s6: string; const s7: string; const s8: string; const s9: string;
const s10: string; const s11: string; const s12: string; const s13: string;
const s14: string; const s15: string; const s16: string; const s17: string;
const s18: string);
begin
end;
procedure TLazLogger.DebugLn(const s: string);
begin
end;
procedure TLazLogger.DebugLn(Args: array of const);
begin
end;
procedure TLazLogger.DebugLn(const S: String; Args: array of const);
begin
end;
procedure TLazLogger.DebugLn(const s1, s2: string; const s3: string; const s4: string;
const s5: string; const s6: string; const s7: string; const s8: string; const s9: string;
const s10: string; const s11: string; const s12: string; const s13: string;
const s14: string; const s15: string; const s16: string; const s17: string;
const s18: string);
begin
end;
procedure TLazLogger.DebugLnEnter(const s: string);
begin
end;
procedure TLazLogger.DebugLnEnter(Args: array of const);
begin
end;
procedure TLazLogger.DebugLnEnter(s: string; Args: array of const);
begin
end;
procedure TLazLogger.DebugLnEnter(const s1, s2: string; const s3: string; const s4: string;
const s5: string; const s6: string; const s7: string; const s8: string; const s9: string;
const s10: string; const s11: string; const s12: string; const s13: string;
const s14: string; const s15: string; const s16: string; const s17: string;
const s18: string);
begin
end;
procedure TLazLogger.DebugLnExit(const s: string);
begin
end;
procedure TLazLogger.DebugLnExit(Args: array of const);
begin
end;
procedure TLazLogger.DebugLnExit(s: string; Args: array of const);
begin
end;
procedure TLazLogger.DebugLnExit(const s1, s2: string; const s3: string; const s4: string;
const s5: string; const s6: string; const s7: string; const s8: string; const s9: string;
const s10: string; const s11: string; const s12: string; const s13: string;
const s14: string; const s15: string; const s16: string; const s17: string;
const s18: string);
begin
end;
procedure TLazLogger.DebuglnStack(LogGroup: PLazLoggerLogGroup; const s: string);
begin
end;
procedure TLazLogger.DbgOut(LogGroup: PLazLoggerLogGroup; const s: string);
begin
end;
procedure TLazLogger.DbgOut(LogGroup: PLazLoggerLogGroup; Args: array of const);
begin
end;
procedure TLazLogger.DbgOut(LogGroup: PLazLoggerLogGroup; const S: String;
Args: array of const);
begin
end;
procedure TLazLogger.DbgOut(LogGroup: PLazLoggerLogGroup; const s1, s2: string;
const s3: string; const s4: string; const s5: string; const s6: string; const s7: string;
const s8: string; const s9: string; const s10: string; const s11: string; const s12: string;
const s13: string; const s14: string; const s15: string; const s16: string;
const s17: string; const s18: string);
begin
end;
procedure TLazLogger.DebugLn(LogGroup: PLazLoggerLogGroup; const s: string);
begin
end;
procedure TLazLogger.DebugLn(LogGroup: PLazLoggerLogGroup; Args: array of const);
begin
end;
procedure TLazLogger.DebugLn(LogGroup: PLazLoggerLogGroup; const S: String;
Args: array of const);
begin
end;
procedure TLazLogger.DebugLn(LogGroup: PLazLoggerLogGroup; const s1, s2: string;
const s3: string; const s4: string; const s5: string; const s6: string; const s7: string;
const s8: string; const s9: string; const s10: string; const s11: string; const s12: string;
const s13: string; const s14: string; const s15: string; const s16: string;
const s17: string; const s18: string);
begin
end;
procedure TLazLogger.DebugLnEnter(LogGroup: PLazLoggerLogGroup; const s: string);
begin
end;
procedure TLazLogger.DebugLnEnter(LogGroup: PLazLoggerLogGroup; Args: array of const);
begin
end;
procedure TLazLogger.DebugLnEnter(LogGroup: PLazLoggerLogGroup; s: string;
Args: array of const);
begin
end;
procedure TLazLogger.DebugLnEnter(LogGroup: PLazLoggerLogGroup; const s1, s2: string;
const s3: string; const s4: string; const s5: string; const s6: string; const s7: string;
const s8: string; const s9: string; const s10: string; const s11: string; const s12: string;
const s13: string; const s14: string; const s15: string; const s16: string;
const s17: string; const s18: string);
begin
end;
procedure TLazLogger.DebugLnExit(LogGroup: PLazLoggerLogGroup; const s: string);
begin
end;
procedure TLazLogger.DebugLnExit(LogGroup: PLazLoggerLogGroup; Args: array of const);
begin
end;
procedure TLazLogger.DebugLnExit(LogGroup: PLazLoggerLogGroup; s: string;
Args: array of const);
begin
end;
procedure TLazLogger.DebugLnExit(LogGroup: PLazLoggerLogGroup; const s1, s2: string;
const s3: string; const s4: string; const s5: string; const s6: string; const s7: string;
const s8: string; const s9: string; const s10: string; const s11: string; const s12: string;
const s13: string; const s14: string; const s15: string; const s16: string;
const s17: string; const s18: string);
begin
end;
{ TLazLoggerLogGroupList }
function TLazLoggerLogGroupList.GetItem(Index: Integer): PLazLoggerLogGroup;
begin
Result := nil;
end;
procedure TLazLoggerLogGroupList.Assign(Src: TLazLoggerLogGroupList);
begin
end;
function TLazLoggerLogGroupList.IndexOf(const AConfigName: String): integer;
begin
Result := -1;
end;
function TLazLoggerLogGroupList.IndexOf(const AnEntry: PLazLoggerLogGroup): integer;
begin
Result := -1;
end;
function TLazLoggerLogGroupList.Find(const AConfigName: String): PLazLoggerLogGroup;
begin
Result := nil;
end;
function TLazLoggerLogGroupList.Count: integer;
begin
Result := 0;
end;
finalization // Using TObject, so if none of the functions is used in the app, then even the rlass should be smart linked
ReleaseRefAndNil(TheLazLogger);
ReleaseRefAndNil(TheLazLoggerGroups);
end.
|