forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log4javascript.d.ts
1118 lines (927 loc) · 38.1 KB
/
log4javascript.d.ts
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
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for log4javascript v1.4.13
// Project: http://log4javascript.org/
// Definitions by: Markus Wagner <https://github.com/Ritzlgrmft/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace log4javascript {
// #region log4javascript static properties/methods
/**
* Returns a logger with the specified name, creating it if a logger with that name does not already exist.
* If no name is specified, a logger is returned with name [anonymous], and subsequent calls to getLogger()
* (with no logger name specified) will return this same logger object.
* Note that the names [anonymous], [default], [null] and root are reserved for the anonymous logger, default logger,
* null logger and root logger respectively.
*/
export function getLogger(loggerName?: string): Logger;
/**
* Convenience method that returns the default logger. The default logger has a single appender: a PopUpAppender with the default
* layout, width and height, and with focusPopUp set to false and lazyInit, useOldPopUp and complainAboutPopUpBlocking all set to true.
*/
export function getDefaultLogger(): Logger;
/**
* Returns an empty logger with no appenders. Useful for disabling all logging.
*/
export function getNullLogger(): Logger;
/**
* Returns the root logger from which all other loggers derive.
*/
export function getRootLogger(): Logger;
/**
* Resets the all loggers to their default level.
*/
export function resetConfiguration(): void;
/**
* Enables or disables all logging, depending on enabled.
*/
export function setEnabled(enabled: boolean): void;
/**
* Returns true or false depending on whether logging is enabled.
*/
export function isEnabled(): boolean;
/**
* Adds a function to be called when an event of the type specified occurs in log4javascript.
* Supported event types are load (occurs once the page has loaded) and error.
*/
export function addEventListener(eventType: string, listener: { (sender: any, eventType: string, eventArgs: any): void; }): void;
/**
* Removes the event listener function supplied for the event of the type specified.
*/
export function removeEventListener(eventType: string, listener: { (sender: any, eventType: string, eventArgs: any): void; }): void;
/**
* Raises an event of type eventType on the log4javascript object. Each of the listeners for this type of event
* (registered via addEventListener) is called and passed eventArgs as the third parameter.
*/
export function dispatchEvent(eventType: string, eventArgs: any): void;
/**
* Used internally to specify the types of events that the log4javascript object can raise.
*/
export function setEventTypes(eventTypes: string[]): void;
/**
* Enables or disables displaying of error stack traces, depending on show. By default, stack traces are not displayed.
* (Only works in Firefox)
*/
export function setShowStackTraces(show: boolean): void;
/**
* This evaluates the given expression in the log4javascript scope, thus allowing scripts to access internal
* log4javascript variables and functions. This was written for the purposes of automated testing but could be used by
* custom extensions to log4javascript.
*/
export function evalInScope(expr: string): any;
// #endregion
// #region Levels
/**
* Levels are available as static properties of the log4javascript.Level object.
*/
export class Level {
static ALL: Level;
static TRACE: Level;
static DEBUG: Level;
static INFO: Level;
static WARN: Level;
static ERROR: Level;
static FATAL: Level;
static OFF: Level;
constructor(level: number, name: string);
toString(): string;
equals(level: Level): boolean;
isGreaterOrEqual(level: Level): boolean;
}
// #endregion
// #region Loggers
/**
* It is possible to have multiple loggers in log4javascript. For example, you may wish to have a logger for debugging purposes
* that logs messages to a pop-up window and a separate logger that reports any client-side application errors to the server via Ajax.
* From version 1.4, log4javascript has hierarchical loggers, implemented in the same way as log4j. In summary, you specify a
* logger's parent logger by means of a dot between the parent logger name and the child logger name. Therefore the logger
* tim.app.security inherits from tim.app, which in turn inherits from tim which, finally, inherits from the root logger.
* What inheritance means for a logger is that in the absence of a threshold level set specifically on the logger it inherits
* its level from its parent; also, a logger inherits all its parent's appenders (this is known as appender additivity in log4j.
* This behaviour can be enabled or disabled via setAdditivity(). See below). In the above example, if the root logger has a
* level of DEBUG and one appender, each of the loggers tim.app.security, tim.app and tim would inherit the root level's appender.
* If, say, tim.app's threshold level was set to WARN, tim's effective level would remain at DEBUG (inherited from the root logger)
* while tim.app.security's effective level would be WARN, inherited from tim.app. The important thing to note is that appenders
* accumulate down the logger hierarchy while levels are simply inherited from the nearest ancestor with a threshold level set.
* For a detailed explanation of the logger hierarchy, see the log4j manual.
*/
export class Logger {
/**
* Adds the given appender.
*/
addAppender(appender: Appender): void;
/**
* Removes the given appender.
*/
removeAppender(appender: Appender): void;
/**
* Clears all appenders for the current logger.
*/
removeAllAppenders(): void;
/**
* Returns all appenders which will log a message.
*/
getEffectiveAppenders(): Appender[];
/**
* Sets the level. Log messages of a lower level than level will not be logged. Default value is DEBUG.
*/
setLevel(level: Level): void;
/**
* Returns the level explicitly set for this logger or null if none has been set.
*/
getLevel(): Level;
/**
* Returns the level at which the logger is operating. This is either the level explicitly set on the logger or, if no level
* has been set, the effective level of the logger's parent.
*/
getEffectiveLevel(): Level;
/**
* Sets whether appender additivity is enabled (the default) or disabled. If set to false, this particular logger will not
* inherit any appenders form its ancestors. Any descendant of this logger, however, will inherit from its ancestors as
* normal, unless its own additivity is explicitly set to false.
* Default value is true.
*/
setAdditivity(additivity: boolean): void;
/**
* Returns whether additivity is enabled for this logger.
*/
getAdditivity(): boolean;
/**
* Generic logging method used by wrapper methods such as debug, error etc.
*/
log(level: Level, params: any[]): void;
/**
* Logs one or more messages and optionally an error at level TRACE.
*/
trace(...messages: any[]): void;
/**
* Logs one or more messages and optionally an error at level DEBUG.
*/
debug(...messages: any[]): void;
/**
* Logs one or more messages and optionally an error at level INFO.
*/
info(...messages: any[]): void;
/**
* Logs one or more messages and optionally an error at level WARN.
*/
warn(...messages: any[]): void;
/**
* Logs one or more messages and optionally an error at level ERROR.
*/
error(...messages: any[]): void;
/**
* Logs one or more messages and optionally an error at level FATAL.
*/
fatal(...messages: any[]): void;
/**
* Returns whether the logger is enabled for the specified level.
*/
isEnabledFor(level: Level, exception: Error): boolean;
/**
* Returns whether the logger is enabled for TRACE messages.
*/
isTraceEnabled(): boolean;
/**
* Returns whether the logger is enabled for DEBUG messages.
*/
isDebugEnabled(): boolean;
/**
* Returns whether the logger is enabled for INFO messages.
*/
isInfoEnabled(): boolean;
/**
* Returns whether the logger is enabled for WARN messages.
*/
isWarnEnabled(): boolean;
/**
* Returns whether the logger is enabled for ERROR messages.
*/
isErrorEnabled(): boolean;
/**
* Returns whether the logger is enabled for FATAL messages.
*/
isFatalEnabled(): boolean;
/**
* Starts a new group of log messages. In appenders that support grouping (currently PopUpAppender and InPageAppender),
* a group appears as an expandable section in the console, labelled with the name specified. Specifying initiallyExpanded
* determines whether the group starts off expanded (the default is true). Groups may be nested.
*/
group(name: string, initiallyExpanded?: boolean): void;
/**
* Ends the current group. If there is no group then this function has no effect.
*/
groupEnd(): void;
/**
* Starts a timer with name name. When the timer is ended with a call to timeEnd using the same name, the amount of time
* that has elapsed in milliseconds since the timer was started is logged at level level. If not level is supplied, the level
* defaults to INFO.
*/
time(name: string, level?: Level): void;
/**
* Ends the timer with name name and logs the time elapsed.
*/
timeEnd(name: string): void;
/**
* Asserts the given expression is true or evaluates to true. If so, nothing is logged. If not, an error is logged at the ERROR level.
*/
assert(expr: any): void;
name: string;
}
// #endregion
// #region Appenders
/**
* Logging event.
*/
export class LoggingEvent {
logger: Logger;
timeStamp: Date;
timeStampInMilliseconds: number;
timeStampInSeconds: number;
milliseconds: number;
level: Level;
messages: any[];
exception: Error;
constructor(logger: Logger, timeStamp: Date, level: Level, messages: string[], exception?: Error);
getThrowableStrRep: () => string;
getCombinedMessages: () => string;
toString: () => string;
}
/**
* There are methods common to all appenders, as listed below.
*/
export class Appender {
/**
* Checks the logging event's level is at least as severe as the appender's threshold and calls the appender's append method if so.
* This method should not in general be used directly or overridden.
*/
doAppend(loggingEvent: LoggingEvent): void;
/**
* Appender-specific method to append a log message. Every appender object should implement this method.
*/
append(loggingEvent: LoggingEvent): void;
/**
* Sets the appender's layout.
*/
setLayout(layout: Layout): void;
/**
* Returns the appender's layout.
*/
getLayout(): Layout;
/**
* Sets the appender's threshold. Log messages of level less severe than this threshold will not be logged.
*/
setThreshold(level: Level): void;
/**
* Returns the appender's threshold.
*/
getThreshold(): Level;
/**
* Returns a string representation of the appender. Every appender object should implement this method.
*/
toString(): string;
}
/**
* Displays a log message as a JavaScript alert.
*/
export class AlertAppender extends Appender {
/**
* Constructor
*/
constructor();
}
/**
* A flexible appender that asynchronously sends log messages to a server via HTTP.
* The default configuration is to send each log message as a separate HTTP post request to the server using an
* HttpPostDataLayout, without waiting for a response before sending any subsequent requests.
*/
export class AjaxAppender extends Appender {
/**
* Constructor
* @param url The URL to which log messages should be sent. Note that this is subject to the usual Ajax restrictions:
* the URL should be in the same domain as that of the page making the request.
* @param withCredentials Specifies whether cookies should be sent with each request.
*/
constructor(url: string, withCredentials?: boolean);
/**
* Whether to send all remaining unsent log messages to the server when the page unloads.
* Since version 1.4.3, the default value is false. Previously the default was true.
*/
setSendAllOnUnload(sendAllOnUnload: boolean): void;
/**
* Returns whether all remaining unsent log messages are sent to the server when the page unloads.
*/
isSendAllOnUnload(): boolean;
/**
* Sets the post variable name whose value will the formatted log message(s) for each request.
* Default value is data.
*/
setPostVarName(postVarName: string): void;
/**
* Returns the post variable name whose value will the formatted log message(s) for each request.
*/
getPostVarName(): string;
/**
* Whether to send log messages to the server at regular, timed intervals.
* Default value is false.
*/
setTimed(timed: boolean): void;
/**
* Returns whether log messages are sent to the server at regular, timed intervals.
*/
isTimed(): boolean;
/**
* Sets whether to wait for a response from a previous HTTP request from this appender before sending the next log
* message / batch of messages.
* Default value is false.
*/
setWaitForResponse(waitForResponse: boolean): void;
/**
* Returns whether the appender waits for a response from a previous HTTP request from this appender before sending the next
* log message / batch of messages.
*/
isWaitForResponse(): boolean;
/**
* Sets the number of log messages to send in each request. If not specified, defaults to 1.
*/
setBatchSize(batchSize: number): void;
/**
* Returns the number of log messages sent in each request. See above for more details.
*/
getBatchSize(): number;
/**
* Sets the length of time in milliseconds between each sending of queued log messages.
*/
setTimerInterval(timerInterval: number): void;
/**
* Returns the length of time in milliseconds between each sending of queued log messages. See above for more details.
*/
getTimerInterval(): number;
/**
* Sets the function that is called whenever a successful request is made, called at the point at which the response is
* received. This feature can be used to confirm whether a request has been successful and act accordingly.
* A single parameter, xmlHttp, is passed to the callback function. This is the XMLHttpRequest object that performed the
* request.
*/
setRequestSuccessCallback(requestSuccessCallback: { (xmlHttp: XMLHttpRequest): void; }): void;
/**
* Sets the function that is called whenever any kind of failure occurs in the appender, including browser deficiencies or
* configuration errors (e.g. supplying a non-existent URL to the appender). This feature can be used to handle
* AjaxAppender-specific errors.
* A single parameter, message, is passed to the callback function. This is the error-specific message that caused the failure.
*/
setFailCallback(failCallback: { (message: string): void; }): void;
/**
* Sets the session id sent to the server each time a request is made.
*/
setSessionId(sessionId: string): void;
/**
* Returns the session id sent to the server each time a request is made.
*/
getSessionId(): string;
/**
* Adds an HTTP header that is sent with each request.
*/
addHeader(name: string, value: string): void;
/**
* Returns an array of the additional headers that are sent with each HTTP request. Each array item is an object with
* properties name and value.
*/
getHeaders(): Array<{ name: string; value: string; }>;
/**
* Sends all log messages in the queue. If log messages are batched then only completed batches are sent.
*/
sendAll(): void;
}
/**
* Logs messages to a pop-up console window (note: you will need to disable pop-up blockers to use it). The pop-up displays a
* list of all log messages.
*/
export class PopUpAppender extends Appender {
/**
* Constructor
* @param lazyInit Set this to true to open the pop-up only when the first log message reaches the appender. Otherwise, the
* pop-up window opens as soon as the appender is created. If not specified, defaults to false.
* @param initiallyMinimized Whether the console window should start off hidden / minimized. If not specified, defaults to false.
* @param useDocumentWrite Specifies how the console window is created. By default, the console window is created dynamically
* using document's write method. This has the advantage of keeping all the code in one single JavaScript file. However,
* if your page sets document.domain then the browser prevents script access to a window unless it too has the same value
* set for document.domain. To get round this issue, you can set useDocumentWrite to false and log4javascript will instead
* use the external HTML file console.html (or console_uncompressed.html if you're using an uncompressed version of
* log4javascript.js), which must be placed in the same directory as your log4javascript.js file.
* Note that if useDocumentWrite is set to true, the old pop-up window will always be closed and a new one created whenever
* the page is refreshed, even if setUseOldPopUp(true) has been called.
* In general it's simpler to use the document.write method, so unless your page needs to set document.domain,
* useDocumentWrite should be set to true.
* If not specified, defaults to true.
* @param width The outer width in pixels of the pop-up window. If not specified, defaults to 600.
* @param height The outer height in pixels of the pop-up window. If not specified, defaults to 400.
*/
constructor(lazyInit?: boolean, initiallyMinimized?: boolean, useDocumentWrite?: boolean, width?: number, height?: number);
/**
* Returns whether the console window starts off hidden / minimized.
*/
isInitiallyMinimized(): boolean;
/**
* Sets whether the console window should start off hidden / minimized.
*/
setInitiallyMinimized(initiallyMinimized: boolean): void;
/**
* Returns whether the pop-up window is focussed (i.e. brought it to the front) when a new log message is added. Default value is false.
*/
isFocusPopUp(): boolean;
/**
* Sets whether to focus the pop-up window (i.e. bring it to the front) when a new log message is added.
*/
setFocusPopUp(focusPopUp: boolean): void;
/**
* Returns whether the same pop-up window is used if the main page is reloaded. If set to true, when the page is reloaded a
* line is drawn in the pop-up and subsequent log messages are added to the same pop-up. Otherwise, a new pop-up window is
* created that replaces the original pop-up. If not specified, defaults to true.
*/
isUseOldPopUp(): boolean;
/**
* Sets whether to use the same pop-up window if the main page is reloaded. See isUseOldPopUp above for details.
*/
setUseOldPopUp(useOldPopUp: boolean): void;
/**
* Returns whether an alert is shown to the user when the pop-up window cannot be created as a result of a pop-up blocker.
* Default value is true.
*/
isComplainAboutPopUpBlocking(): boolean;
/**
* Sets whether to announce to show an alert to the user when the pop-up window cannot be created as a result of a pop-up blocker.
*/
setComplainAboutPopUpBlocking(complainAboutPopUpBlocking: boolean): void;
/**
* Returns whether new log messages are displayed at the top of the pop-up window. Default value is false (i.e. log messages
* are appended to the bottom of the window).
*/
isNewestMessageAtTop(): boolean;
/**
* Sets whether to display new log messages at the top inside the pop-up window.
*/
setNewestMessageAtTop(newestMessageAtTop: boolean): void;
/**
* Returns whether the pop-up window scrolls to display the latest log message when a new message is logged. Default value is true.
*/
isScrollToLatestMessage(): boolean;
/**
* Sets whether to scroll the pop-up window to display the latest log message when a new message is logged.
*/
setScrollToLatestMessage(scrollToLatestMessage: boolean): void;
/**
* Returns whether the pop-up window reopens automatically after being closed when a new log message is logged. Default value is false.
*/
isReopenWhenClosed(): boolean;
/**
* Sets whether to reopen the pop-up window automatically after being closed when a new log message is logged.
*/
setReopenWhenClosed(reopenWhenClosed: boolean): void;
/**
* Returns the outer width in pixels of the pop-up window.
*/
getWidth(): number;
/**
* Sets the outer width in pixels of the pop-up window.
*/
setWidth(width: number): void;
/**
* Returns the outer height in pixels of the pop-up window.
*/
getHeight(): number;
/**
* Sets the outer height in pixels of the pop-up window.
*/
setHeight(height: number): void;
/**
* Returns the largest number of log messages that are displayed and stored by the the console. Once reached, a new log
* message wil cause the oldest message to be discarded. Default value is null, which means no limit is applied.
*/
getMaxMessages(): number;
/**
* Sets the largest number of messages displayed and stored by the console window. Set this to null to make this number unlimited.
*/
setMaxMessages(maxMessages: number): void;
/**
* Returns whether the console includes a command line. Default value is true.
*/
isShowCommandLine(): boolean;
/**
* Sets whether the console includes a command line.
*/
setShowCommandLine(showCommandLine: boolean): void;
/**
* Returns the number of levels to expand when an object value is logged to the console. Each property of an object above
* this threshold will be expanded if it is itself an object or array, otherwise its string representation will be displayed.
* Default value is 1 (i.e. the properties of the object logged will be displayed in their string representation but not expanded).
*/
getCommandLineObjectExpansionDepth(): number;
/**
* Sets the number of levels to expand when an object value is logged to the console.
*/
setCommandLineObjectExpansionDepth(expansionDepth: number): void;
/**
* Returns a reference to the window in which commands typed into the command line are currently being executed.
*/
getCommandWindow(): Window;
/**
* Sets the window in which commands typed into the command line are executed.
*/
setCommandWindow(commandWindow: Window): void;
/**
* Returns the layout used to format the output for commands typed into the command line. The default value is a
* PatternLayout with pattern string %m
*/
getCommandLayout(): Layout;
/**
* Sets the layout used to format the output for commands typed into the command line.
*/
setCommandLayout(commandLayout: Layout): void;
/**
* Clears all messages from the console window.
*/
clear(): void;
/**
* Closes the pop-up window.
*/
close(): void;
/**
* Opens the pop-up window, if not already open.
*/
show(): void;
/**
* Closes the pop-up window.
*/
hide(): void;
/**
* Brings the console window to the top and gives it the focus.
*/
focus(): void;
/**
* Brings the console window to the top and gives the focus to the command line.
*/
focusCommandLine(): void;
/**
* Brings the console window to the top and gives the focus to the search box.
*/
focusSearch(): void;
/**
* Evaluates the expression and appends the result to the console.
*/
evalCommandAndAppend(expr: string): void;
/**
* Adds a function with the name specified to the list of functions available on the command line. This feature may be used
* to add custom functions to the command line.
*/
addCommandLineFunction(functionName: string,
commandLineFunction: { (appender: Appender, args: any, returnValue: { appendResult: boolean; isError: boolean; }): any; }): void;
}
/**
* Logs messages to a console window in the page. The console is identical to that used by the PopUpAppender, except for the
* absence of a 'Close' button.
*/
export class InPageAppender extends Appender {
/**
* Constructor
* @param container The container element for the console window. This should be an HTML element.
* @param lazyInit Set this to true to create the console only when the first log message reaches the appender. Otherwise,
* the console is initialized as soon as the appender is created. If not specified, defaults to true.
* @param initiallyMinimized Whether the console window should start off hidden / minimized. If not specified, defaults to false
* @param useDocumentWrite Specifies how the console window is created. By default, the console window is created dynamically
* using document's write method. This has the advantage of keeping all the code in one single JavaScript file. However,
* if your page sets document.domain then the browser prevents script access to a window unless it too has the same value
* set for document.domain. To get round this issue, you can set useDocumentWrite to false and log4javascript will instead
* use the external HTML file console.html (or console_uncompressed.html if you're using an uncompressed version of
* log4javascript.js), which must be placed in the same directory as your log4javascript.js file.
* In general it's simpler to use the document.write method, so unless your page needs to set document.domain,
* useDocumentWrite should be set to true.
* If not specified, defaults to true.
* @param width The width of the console window. Any valid CSS length may be used. If not specified, defaults to 100%.
* @param height The height of the console window. Any valid CSS length may be used. If not specified, defaults to 250px.
*/
constructor(container: HTMLElement, lazyInit?: boolean, initiallyMinimized?: boolean,
useDocumentWrite?: boolean, width?: number, height?: number);
/**
* Sets a CSS style property on the HTML element containing the console iframe.
*/
addCssProperty(name: string, value: string): void;
/**
* Returns whether the console window is currently visible.
*/
isVisible(): boolean;
/**
* Returns whether the console window starts off hidden / minimized.
*/
isInitiallyMinimized(): boolean;
/**
* Sets whether the console window should start off hidden / minimized.
*/
setInitiallyMinimized(initiallyMinimized: boolean): void;
/**
* Returns whether new log messages are displayed at the top of the pop-up window. Default value is false (i.e. log messages
* are appended to the bottom of the window).
*/
isNewestMessageAtTop(): boolean;
/**
* Sets whether to display new log messages at the top inside the pop-up window.
*/
setNewestMessageAtTop(newestMessageAtTop: boolean): void;
/**
* Returns whether the pop-up window scrolls to display the latest log message when a new message is logged. Default value is true.
*/
isScrollToLatestMessage(): boolean;
/**
* Sets whether to scroll the pop-up window to display the latest log message when a new message is logged.
*/
setScrollToLatestMessage(scrollToLatestMessage: boolean): void;
/**
* Returns the outer width of the console window.
*/
getWidth(): number;
/**
* Sets the outer width of the console window. Any valid CSS length may be used.
*/
setWidth(width: number): void;
/**
* Returns the outer height of the console window.
*/
getHeight(): number;
/**
* Sets the outer height of the console window. Any valid CSS length may be used.
*/
setHeight(height: number): void;
/**
* Returns the largest number of messages displayed and stored by the console window.
*/
getMaxMessages(): number;
/**
* Sets the largest number of messages displayed and stored by the console window. Set this to null to make this number unlimited.
*/
setMaxMessages(maxMessages: number): void;
/**
* Returns whether the console includes a command line. Default value is true.
*/
isShowCommandLine(): boolean;
/**
* Sets whether the console includes a command line.
*/
setShowCommandLine(showCommandLine: boolean): void;
/**
* Returns the number of levels to expand when an object value is logged to the console. Each property of an object above
* this threshold will be expanded if it is itself an object or array, otherwise its string representation will be displayed.
* Default value is 1 (i.e. the properties of the object logged will be displayed in their string representation but not expanded).
*/
getCommandLineObjectExpansionDepth(): number;
/**
* Sets the number of levels to expand when an object value is logged to the console.
*/
setCommandLineObjectExpansionDepth(expansionDepth: number): void;
/**
* Returns a reference to the window in which commands typed into the command line are currently being executed.
*/
getCommandWindow(): Window;
/**
* Sets the window in which commands typed into the command line are executed.
*/
setCommandWindow(commandWindow: Window): void;
/**
* Returns the layout used to format the output for commands typed into the command line. The default value is a
* PatternLayout with pattern string %m
*/
getCommandLayout(): Layout;
/**
* Sets the layout used to format the output for commands typed into the command line.
*/
setCommandLayout(commandLayout: Layout): void;
/**
* Clears all messages from the console window.
*/
clear(): void;
/**
* Closes the pop-up window.
*/
close(): void;
/**
* Shows / unhides the console window.
*/
show(): void;
/**
* Hides / minimizes the console window.
*/
hide(): void;
/**
* Brings the console window to the top and gives it the focus.
*/
focus(): void;
/**
* Brings the console window to the top and gives the focus to the command line.
*/
focusCommandLine(): void;
/**
* Brings the console window to the top and gives the focus to the search box.
*/
focusSearch(): void;
/**
* Evaluates the expression and appends the result to the console.
*/
evalCommandAndAppend(expr: string): void;
/**
* Adds a function with the name specified to the list of functions available on the command line. This feature may be used
* to add custom functions to the command line.
*/
addCommandLineFunction(functionName: string,
commandLineFunction: { (appender: Appender, args: any, returnValue: { appendResult: boolean; isError: boolean; }): any; }): void;
}
/**
* Writes log messages to the browser's built-in console, if present. This only works currently in Safari, Opera and Firefox
* with the excellent Firebug extension installed.
*/
export class BrowserConsoleAppender extends Appender {
/**
* Constructor
*/
constructor();
}
//#endregion
// #region Layouts
/**
* There are a few methods common to all layouts.
*/
export class Layout {
/**
* Formats the log message. You should override this method in your own layouts.
*/
format(loggingEvent: LoggingEvent): string;
/**
* Returns whether the layout ignores an error object in a logging event passed to its format method.
*/
ignoresThrowable(): boolean;
/**
* Returns the content type of the output of the layout.
*/
getContentType(): string;
/**
* Returns whether the layout's output is suitable for batching. JsonLayout and XmlLayout are the only built-in layouts that
* return true for this method.
*/
allowBatching(): boolean;
/**
* Used internally by log4javascript in constructing formatted output for some layouts.
*/
getDataValues(loggingEvent: LoggingEvent): Array<any>;
/**
* This method is used to change the default keys used to create formatted name-value pairs for the properties of a log
* message, for layouts that do this. These layouts are JsonLayout and HttpPostDataLayout.
* @param loggerKey Parameter to use for the log message's logger name. Default is logger.
* @param timeStampKey Parameter to use for the log message's timestamp. Default is timestamp.
* @param levelKey Parameter to use for the log message's level. Default is level.
* @param messageKey Parameter to use for the message itself. Default is message.
* @param exceptionKey Parameter to use for the log message's error (exception). Default is exception.
* @param urlKey Parameter to use for the current page URL. Default is url.
*/
setKeys(loggerKey: string, timeStampKey: string, levelKey: string, messageKey: string, exceptionKey: string, urlKey: string): void;
/**
* Some layouts (JsonLayout, HttpPostDataLayout, PatternLayout and XmlLayout) allow you to set custom fields (e.g. a session
* id to send to the server) to the formatted output. Use this method to set a custom field. If there is already a custom
* field with the specified name, its value will be updated with value.
* @param name Name of the custom property you wish to be included in the formmtted output.
* @param value Value of the custom property you wish to be included in the formatted output.
*/
setCustomField(name: string, value: string): string;
/**
* Returns whether the layout has any custom fields.
*/
hasCustomFields(): boolean;
formatWithException(loggingEvent: LoggingEvent): string;
}
/**
* The most basic layout. NullLayout's format() methods performs no formatting at all and simply returns the message logged.
*/
export class NullLayout extends Layout {
/**
* Constructor
*/
constructor();
}
/**
* Provides basic formatting. SimpleLayout consists of the level of the log statement, followed by " - " and then the log message
* itself. For example, "DEBUG - Hello world".
*/
export class SimpleLayout extends Layout {
/**
* Constructor
*/
constructor();
}
/**
* Provides a flexible way of formatting a log message by means of a conversion pattern string. The behaviour of this layout is a
* full implementation of PatternLayout in log4j, with the exception of the set of conversion characters - log4javascript's is
* necessarily a subset of that of log4j with a few additions of its own, since many of the conversion characters in log4j only
* make sense in the context of Java.
* The conversion pattern consists of literal text interspersed with special strings starting with a % symbol called conversion
* specifiers. A conversion specifier consists of the % symbol, a conversion character (possible characters are listed below) and
* format modifiers. For full documentation of the conversion pattern, see log4j's documentation.
*/
export class PatternLayout extends Layout {
/**
* Built-in conversion pattern, equivalent to %r %p %c - %m%n.
*/
static TTCC_CONVERSION_PATTERN: string;
/**