ionic-logging-service 18.0.0 → 21.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +11 -21
  2. package/fesm2022/ionic-logging-service.mjs +42 -72
  3. package/fesm2022/ionic-logging-service.mjs.map +1 -1
  4. package/package.json +9 -8
  5. package/types/ionic-logging-service.d.ts +643 -0
  6. package/esm2022/ionic-logging-service.mjs +0 -5
  7. package/esm2022/lib/ajax-appender.configuration.mjs +0 -2
  8. package/esm2022/lib/ajax-appender.model.mjs +0 -149
  9. package/esm2022/lib/browser-console-appender.configuration.mjs +0 -2
  10. package/esm2022/lib/json-layout.model.mjs +0 -31
  11. package/esm2022/lib/local-storage-appender.configuration.mjs +0 -2
  12. package/esm2022/lib/local-storage-appender.model.mjs +0 -177
  13. package/esm2022/lib/log-level.converter.mjs +0 -92
  14. package/esm2022/lib/log-level.model.mjs +0 -47
  15. package/esm2022/lib/log-message.model.mjs +0 -2
  16. package/esm2022/lib/logger.model.mjs +0 -191
  17. package/esm2022/lib/logging-service.configuration.mjs +0 -2
  18. package/esm2022/lib/logging-service.module.mjs +0 -16
  19. package/esm2022/lib/logging.service.mjs +0 -167
  20. package/esm2022/lib/memory-appender.configuration.mjs +0 -2
  21. package/esm2022/lib/memory-appender.model.mjs +0 -133
  22. package/esm2022/public_api.mjs +0 -18
  23. package/index.d.ts +0 -5
  24. package/lib/ajax-appender.configuration.d.ts +0 -37
  25. package/lib/ajax-appender.model.d.ts +0 -92
  26. package/lib/browser-console-appender.configuration.d.ts +0 -13
  27. package/lib/json-layout.model.d.ts +0 -20
  28. package/lib/local-storage-appender.configuration.d.ts +0 -23
  29. package/lib/local-storage-appender.model.d.ts +0 -95
  30. package/lib/log-level.converter.d.ts +0 -28
  31. package/lib/log-level.model.d.ts +0 -37
  32. package/lib/log-message.model.d.ts +0 -25
  33. package/lib/logger.model.d.ts +0 -88
  34. package/lib/logging-service.configuration.d.ts +0 -40
  35. package/lib/logging-service.module.d.ts +0 -6
  36. package/lib/logging.service.d.ts +0 -84
  37. package/lib/memory-appender.configuration.d.ts +0 -19
  38. package/lib/memory-appender.model.d.ts +0 -81
  39. package/public_api.d.ts +0 -14
@@ -1,37 +0,0 @@
1
- /**
2
- * Configuration for AjaxAppender.
3
- */
4
- export interface AjaxAppenderConfiguration {
5
- /**
6
- * Url to send JavaScript logs
7
- */
8
- url: string;
9
- /**
10
- * Specifies whether cookies should be sent with each request.
11
- *
12
- * Default: false.
13
- */
14
- withCredentials?: boolean;
15
- /**
16
- * Number of log messages sent in each request.
17
- *
18
- * Default: 1.
19
- */
20
- batchSize?: number;
21
- /**
22
- * Interval for sending log messages (in milliseconds).
23
- *
24
- * If set to 0, every message will be sent immediatedly.
25
- *
26
- * Default: 0.
27
- */
28
- timerInterval?: number;
29
- /**
30
- * Threshold.
31
- *
32
- * Valid values are: ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN
33
- *
34
- * Default: WARN.
35
- */
36
- threshold?: string;
37
- }
@@ -1,92 +0,0 @@
1
- import { EventEmitter } from "@angular/core";
2
- import * as log4javascript from "log4javascript";
3
- import { AjaxAppenderConfiguration } from "./ajax-appender.configuration";
4
- /**
5
- * An appender which sends the log messages to a server via HTTP.
6
- *
7
- * A typical configuration could be:
8
- *
9
- * ```json
10
- * {
11
- * "url": "https://my.backend.xy/LoggingBackend",
12
- * "batchSize": 10,
13
- * "timerInterval": 60000,
14
- * "threshold": "INFO"
15
- * }
16
- * ```
17
- */
18
- export declare class AjaxAppender extends log4javascript.Appender {
19
- private static batchSizeDefault;
20
- private static timerIntervalDefault;
21
- private static thresholdDefault;
22
- /**
23
- * Event triggered when the appender could not send log messages to the server.
24
- *
25
- * @param message error message
26
- */
27
- appenderFailed: EventEmitter<string>;
28
- private ajaxAppender;
29
- private url;
30
- private withCredentials;
31
- /**
32
- * Creates a new instance of the appender.
33
- *
34
- * @param configuration configuration for the appender.
35
- */
36
- constructor(configuration: AjaxAppenderConfiguration);
37
- /**
38
- * Configures the logging depending on the given configuration.
39
- *
40
- * Only the defined properties get overwritten.
41
- * Neither url nor withCredentials can be modified.
42
- *
43
- * @param configuration configuration data.
44
- */
45
- configure(configuration: AjaxAppenderConfiguration): void;
46
- /**
47
- * Appender-specific method to append a log message.
48
- *
49
- * @param loggingEvent event to be appended.
50
- */
51
- append(loggingEvent: log4javascript.LoggingEvent): void;
52
- /**
53
- * Gets the appender's name.
54
- * Mainly for unit testing purposes.
55
- *
56
- * @return appender's name
57
- */
58
- toString(): string;
59
- /**
60
- * Get the internally used appender.
61
- * Mainly for unit testing purposes.
62
- */
63
- getInternalAppender(): log4javascript.AjaxAppender;
64
- /**
65
- * Returns the number of log messages sent in each request.
66
- */
67
- getBatchSize(): number;
68
- /**
69
- * Sets the number of log messages to send in each request.
70
- *
71
- * @param batchSize new batch size
72
- */
73
- setBatchSize(batchSize: number): void;
74
- /**
75
- * Returns the appender's layout.
76
- */
77
- getLayout(): log4javascript.Layout;
78
- /**
79
- * Sets the appender's layout.
80
- */
81
- setLayout(layout: log4javascript.Layout): void;
82
- /**
83
- * Returns the length of time in milliseconds between each sending of queued log messages.
84
- */
85
- getTimerInterval(): number;
86
- /**
87
- * Sets the length of time in milliseconds between each sending of queued log messages.
88
- *
89
- * @param timerInterval new timer interval
90
- */
91
- setTimerInterval(timerInterval: number): void;
92
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * Configuration for BrowserConsoleAppender.
3
- */
4
- export interface BrowserConsoleAppenderConfiguration {
5
- /**
6
- * Threshold.
7
- *
8
- * Valid values are: ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN
9
- *
10
- * Default: DEBUG.
11
- */
12
- threshold?: string;
13
- }
@@ -1,20 +0,0 @@
1
- import * as log4javascript from "log4javascript";
2
- import { LoggingEvent } from "log4javascript";
3
- /**
4
- * Formats a logging event into JavaScript Object Notation (JSON).
5
- * The implemenatation is mainly the same as with log4javascript.JsonLayout,
6
- * with an improvement of serializing messages containing '\"'."
7
- */
8
- export declare class JsonLayout extends log4javascript.JsonLayout {
9
- /**
10
- * Formats the log message.
11
- */
12
- format(loggingEvent: LoggingEvent): string;
13
- /**
14
- * Gets the layout's name.
15
- * Mainly for unit testing purposes.
16
- *
17
- * @return layout's name
18
- */
19
- toString(): string;
20
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * Configuration for LocalStorageAppender.
3
- */
4
- export interface LocalStorageAppenderConfiguration {
5
- /**
6
- * Key which is used to store the messages in the local storage.
7
- */
8
- localStorageKey: string;
9
- /**
10
- * Maximum number of log messages stored by the appender.
11
- *
12
- * Default: 250.
13
- */
14
- maxMessages?: number;
15
- /**
16
- * Threshold.
17
- *
18
- * Valid values are: ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN
19
- *
20
- * Default: WARN.
21
- */
22
- threshold?: string;
23
- }
@@ -1,95 +0,0 @@
1
- import * as log4javascript from "log4javascript";
2
- import { LocalStorageAppenderConfiguration } from "./local-storage-appender.configuration";
3
- import { LogMessage } from "./log-message.model";
4
- /**
5
- * An appender which stores the log messages in the browser's local storage.
6
- *
7
- * The messages are saved JSON-serialized.
8
- * You have to configure which key is used for storing the messages.
9
- *
10
- * A typical configuration could be:
11
- *
12
- * ```json
13
- * {
14
- * "localStorageKey": "myLogs",
15
- * "maxMessages": 500,
16
- * "threshold": "INFO"
17
- * }
18
- * ```
19
- */
20
- export declare class LocalStorageAppender extends log4javascript.Appender {
21
- private static maxMessagesDefault;
22
- private static thresholdDefault;
23
- private maxMessages;
24
- private localStorageKey;
25
- private logMessages;
26
- /**
27
- * Creates a new instance of the appender.
28
- *
29
- * @param configuration configuration for the appender.
30
- */
31
- constructor(configuration: LocalStorageAppenderConfiguration);
32
- /**
33
- * Load log messages from local storage which are stored there under the given key.
34
- *
35
- * @param localStorageKey local storage key
36
- * @return stored messages
37
- */
38
- static loadLogMessages(localStorageKey: string): LogMessage[];
39
- /**
40
- * Remove log messages from local storage which are stored there under the given key.
41
- *
42
- * @param localStorageKey local storage key
43
- */
44
- static removeLogMessages(localStorageKey: string): void;
45
- /**
46
- * Configures the logging depending on the given configuration.
47
- *
48
- * Only the defined properties get overwritten.
49
- * The localStorageKey cannot be modified.
50
- *
51
- * @param configuration configuration data.
52
- */
53
- configure(configuration: LocalStorageAppenderConfiguration): void;
54
- /**
55
- * Appender-specific method to append a log message.
56
- *
57
- * @param loggingEvent event to be appended.
58
- */
59
- append(loggingEvent: log4javascript.LoggingEvent): void;
60
- /**
61
- * Gets the appender's name.
62
- * Mainly for unit testing purposes.
63
- *
64
- * @return appender's name
65
- */
66
- toString(): string;
67
- /**
68
- * Get the key which is used to store the messages in the local storage.
69
- */
70
- getLocalStorageKey(): string;
71
- /**
72
- * Get the maximum number of messages which will be stored in local storage.
73
- */
74
- getMaxMessages(): number;
75
- /**
76
- * Set the maximum number of messages which will be stored in local storage.
77
- *
78
- * If the appender stores currently more messages than the new value allows, the oldest messages get removed.
79
- *
80
- * @param value new maximum number
81
- */
82
- setMaxMessages(value: number): void;
83
- /**
84
- * Gets all messages stored in local storage.
85
- * Mainly for unit testing purposes.
86
- *
87
- * @return stored messages
88
- */
89
- getLogMessages(): LogMessage[];
90
- /**
91
- * Removes all messages from local storage.
92
- * Mainly for unit testing purposes.
93
- */
94
- clearLog(): void;
95
- }
@@ -1,28 +0,0 @@
1
- import * as log4javascript from "log4javascript";
2
- import { LogLevel } from "./log-level.model";
3
- /**
4
- * Helper class for converting log levels from and to different data type.
5
- */
6
- export declare class LogLevelConverter {
7
- /**
8
- * Converts log4javascript.Level to internal LogLevel.
9
- *
10
- * @param level log4javascript's data type
11
- * @return internal data type.
12
- */
13
- static levelFromLog4Javascript(level: log4javascript.Level): LogLevel;
14
- /**
15
- * Converts string representation to internal LogLevel.
16
- *
17
- * @param level string representation
18
- * @return internal data type.
19
- */
20
- static levelFromString(level: string): LogLevel;
21
- /**
22
- * Converts internal LogLevel to log4javascript.Level.
23
- *
24
- * @param internal data type.
25
- * @return level log4javascript's data type
26
- */
27
- static levelToLog4Javascript(level: LogLevel): log4javascript.Level;
28
- }
@@ -1,37 +0,0 @@
1
- /**
2
- * Logging levels.
3
- */
4
- export declare enum LogLevel {
5
- /**
6
- * All events should be logged.
7
- */
8
- ALL = 0,
9
- /**
10
- * A fine-grained debug message, typically capturing the flow through the application.
11
- */
12
- TRACE = 1,
13
- /**
14
- * A general debugging event.
15
- */
16
- DEBUG = 2,
17
- /**
18
- * An event for informational purposes.
19
- */
20
- INFO = 3,
21
- /**
22
- * An event that might possible lead to an error.
23
- */
24
- WARN = 4,
25
- /**
26
- * An error in the application, possibly recoverable.
27
- */
28
- ERROR = 5,
29
- /**
30
- * A severe error that will prevent the application from continuing.
31
- */
32
- FATAL = 6,
33
- /**
34
- * No events will be logged.
35
- */
36
- OFF = 7
37
- }
@@ -1,25 +0,0 @@
1
- /**
2
- * Log message.
3
- */
4
- export interface LogMessage {
5
- /**
6
- * Time when the log was written.
7
- */
8
- timeStamp: Date;
9
- /**
10
- * Log level.
11
- */
12
- level: string;
13
- /**
14
- * Name of the logger.
15
- */
16
- logger: string;
17
- /**
18
- * Method, in which the message was written.
19
- */
20
- methodName: string;
21
- /**
22
- * Message.
23
- */
24
- message: string[];
25
- }
@@ -1,88 +0,0 @@
1
- import * as log4javascript from "log4javascript";
2
- import { LogLevel } from "./log-level.model";
3
- /**
4
- * Logger for writing log messages.
5
- */
6
- export declare class Logger {
7
- private logger;
8
- /**
9
- * Creates a new instance of a logger.
10
- */
11
- constructor(logger?: string | any);
12
- /**
13
- * Get the log level.
14
- */
15
- getLogLevel(): LogLevel;
16
- /**
17
- * Set the log level.
18
- *
19
- * @param level the new log level
20
- */
21
- setLogLevel(level: LogLevel): void;
22
- /**
23
- * Logs a message at level TRACE.
24
- *
25
- * @param methodName name of the method
26
- * @param params optional parameters to be logged; objects will be formatted as JSON
27
- */
28
- trace(methodName: string, ...params: any[]): void;
29
- /**
30
- * Logs a message at level DEBUG.
31
- *
32
- * @param methodName name of the method
33
- * @param params optional parameters to be logged; objects will be formatted as JSON
34
- */
35
- debug(methodName: string, ...params: any[]): void;
36
- /**
37
- * Logs a message at level INFO.
38
- *
39
- * @param methodName name of the method
40
- * @param params optional parameters to be logged; objects will be formatted as JSON
41
- */
42
- info(methodName: string, ...params: any[]): void;
43
- /**
44
- * Logs a message at level WARN.
45
- *
46
- * @param methodName name of the method
47
- * @param params optional parameters to be logged; objects will be formatted as JSON
48
- */
49
- warn(methodName: string, ...params: any[]): void;
50
- /**
51
- * Logs a message at level ERROR.
52
- *
53
- * @param methodName name of the method
54
- * @param params optional parameters to be logged; objects will be formatted as JSON
55
- */
56
- error(methodName: string, ...params: any[]): void;
57
- /**
58
- * Logs a message at level FATAL.
59
- *
60
- * @param methodName name of the method
61
- * @param params optional parameters to be logged; objects will be formatted as JSON
62
- */
63
- fatal(methodName: string, ...params: any[]): void;
64
- /**
65
- * Logs the entry into a method.
66
- * The method name will be logged at level INFO, the parameters at level DEBUG.
67
- *
68
- * @param methodName name of the method
69
- * @param params optional parameters to be logged; objects will be formatted as JSON
70
- */
71
- entry(methodName: string, ...params: any[]): void;
72
- /**
73
- * Logs the exit of a method.
74
- * The method name will be logged at level INFO, the parameters at level DEBUG.
75
- *
76
- * @param methodName name of the method
77
- * @param params optional parameters to be logged; objects will be formatted as JSON
78
- */
79
- exit(methodName: string, ...params: any[]): void;
80
- /**
81
- * Formats the given argument.
82
- */
83
- formatArgument(arg: any): string;
84
- /**
85
- * Returns the internal Logger (for unit tests only).
86
- */
87
- getInternalLogger(): log4javascript.Logger;
88
- }
@@ -1,40 +0,0 @@
1
- import { AjaxAppenderConfiguration } from "./ajax-appender.configuration";
2
- import { BrowserConsoleAppenderConfiguration } from "./browser-console-appender.configuration";
3
- import { LocalStorageAppenderConfiguration } from "./local-storage-appender.configuration";
4
- import { MemoryAppenderConfiguration } from "./memory-appender.configuration";
5
- /**
6
- * Partial configuration definition for LoggingService.
7
- */
8
- export interface LoggingServiceConfiguration {
9
- /**
10
- * Log levels for different loggers.
11
- * Default: root: WARN
12
- */
13
- logLevels?: Array<{
14
- /**
15
- * Logger name or "root" for root logger.
16
- */
17
- loggerName: string;
18
- /**
19
- * Log level.
20
- * Valid values are: ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN
21
- */
22
- logLevel: string;
23
- }>;
24
- /**
25
- * Settings for AjaxAppender.
26
- */
27
- ajaxAppender?: AjaxAppenderConfiguration;
28
- /**
29
- * Settings for LocalStorageAppender.
30
- */
31
- localStorageAppender?: LocalStorageAppenderConfiguration;
32
- /**
33
- * Settings for MemoryAppender.
34
- */
35
- memoryAppender?: MemoryAppenderConfiguration;
36
- /**
37
- * Settings for BrowserConsoleAppender.
38
- */
39
- browserConsoleAppender?: BrowserConsoleAppenderConfiguration;
40
- }
@@ -1,6 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- export declare class LoggingServiceModule {
3
- static ɵfac: i0.ɵɵFactoryDeclaration<LoggingServiceModule, never>;
4
- static ɵmod: i0.ɵɵNgModuleDeclaration<LoggingServiceModule, never, never, never>;
5
- static ɵinj: i0.ɵɵInjectorDeclaration<LoggingServiceModule>;
6
- }
@@ -1,84 +0,0 @@
1
- import { EventEmitter } from "@angular/core";
2
- import { LogMessage } from "./log-message.model";
3
- import { Logger } from "./logger.model";
4
- import { LoggingServiceConfiguration } from "./logging-service.configuration";
5
- import * as i0 from "@angular/core";
6
- /**
7
- * Service for logging functionality.
8
- *
9
- * By default, the following settings are used:
10
- * - logger: root with level WARN
11
- * - appender: BrowserConsoleAppender with threshold DEBUG and MemoryAppender with threshold ALL
12
- *
13
- * Via [configure](#configure), it is possible to amend these settings.
14
- */
15
- export declare class LoggingService {
16
- /**
17
- * Event triggered when the log messages got (potentially) change.
18
- * This can happen when:
19
- * - new message was added
20
- * - all message where removed from memory
21
- * - all massages where removed for one spcific LocalStorageAppender
22
- */
23
- logMessagesChanged: EventEmitter<void>;
24
- /**
25
- * Event triggered when ajax appender could not send log messages to the server.
26
- *
27
- * @param message error message
28
- */
29
- ajaxAppenderFailed: EventEmitter<string>;
30
- private memoryAppender;
31
- private browserConsoleAppender;
32
- /**
33
- * Creates a new instance of the service.
34
- */
35
- constructor();
36
- /**
37
- * Configures the logging depending on the given configuration.
38
- *
39
- * @param configuration configuration data.
40
- */
41
- configure(configuration?: LoggingServiceConfiguration): void;
42
- /**
43
- * Gets the root logger from which all other loggers derive.
44
- *
45
- * @return root logger
46
- */
47
- getRootLogger(): Logger;
48
- /**
49
- * Gets a logger with the specified name, creating it if a logger with that name does not already exist.
50
- *
51
- * @param loggerName name of the logger
52
- * @return logger
53
- */
54
- getLogger(loggerName: string): Logger;
55
- /**
56
- * Gets the last log messages.
57
- *
58
- * The log messages are retrieved from the internal [MemoryAppender](../memoryappender.html).
59
- * That means you will get only the most current messages. The number of the messages is limited
60
- * by its maxMessages value.
61
- *
62
- * @return log messages
63
- */
64
- getLogMessages(): LogMessage[];
65
- /**
66
- * Loads the log messages written by the LocalStorageAppender with the given key.
67
- *
68
- * @param localStorageKey key for the local storage
69
- * @returns log messages
70
- */
71
- getLogMessagesFromLocalStorage(localStorageKey: string): LogMessage[];
72
- /**
73
- * Remove all log messages.
74
- */
75
- removeLogMessages(): void;
76
- /**
77
- * Removes the log messages written by the LocalStorageAppender with the given key.
78
- *
79
- * @param localStorageKey key for the local storage
80
- */
81
- removeLogMessagesFromLocalStorage(localStorageKey: string): void;
82
- static ɵfac: i0.ɵɵFactoryDeclaration<LoggingService, never>;
83
- static ɵprov: i0.ɵɵInjectableDeclaration<LoggingService>;
84
- }
@@ -1,19 +0,0 @@
1
- /**
2
- * Configuration for MemoryAppender.
3
- */
4
- export interface MemoryAppenderConfiguration {
5
- /**
6
- * Maximum number of log messages stored by the appender.
7
- *
8
- * Default: 250.
9
- */
10
- maxMessages?: number;
11
- /**
12
- * Threshold.
13
- *
14
- * Valid values are: ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN.
15
- *
16
- * Default: ALL.
17
- */
18
- threshold?: string;
19
- }