@epigraph/epigraph-std-lib 1.0.0 → 2.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.
@@ -1,19 +1,130 @@
1
- type ILoggerDetails = string | boolean | object | Array<string> | Array<boolean> | HTMLElement;
1
+ interface LoggerMode {
2
+ name: string;
3
+ allows: Array<string>;
4
+ }
5
+ interface LoggerModes {
6
+ release: LoggerMode;
7
+ staging: LoggerMode;
8
+ dev: LoggerMode;
9
+ }
10
+ export declare enum LoggerModeNames {
11
+ Release = "release",
12
+ Staging = "staging",
13
+ Dev = "dev"
14
+ }
15
+ export declare enum LogTypes {
16
+ Info = "info",
17
+ Warn = "warn",
18
+ Error = "error"
19
+ }
2
20
  /**
3
- * Temporary class to use instead of console.log so it's
4
- * easy to migrate int he future.
21
+ * Epigraph's Logger class that provides various modes and functionalities to easily
22
+ * manage logging within our solutions in a consistent manner.
23
+ *
24
+ * Some common terminologies are:
25
+ * Mode: A logger's mode defines what log types would be automatically executed and
26
+ * what would be ignored.
5
27
  */
6
28
  declare class EpigraphLogger {
7
29
  context: string;
30
+ private _allModes;
31
+ private _currentMode;
8
32
  /**
9
33
  * @param {string} [context="EPIGRAPH-LOGGER"] Used to categorise each message within
10
34
  * the console.
11
35
  * @example,CORE, UI
12
36
  */
13
37
  constructor(context: string);
14
- log(title?: string, details?: ILoggerDetails): void;
15
- warn(title?: string, details?: ILoggerDetails): void;
16
- error(title?: string, details?: ILoggerDetails): void;
17
- table(title?: string, details?: ILoggerDetails): void;
38
+ get modes(): LoggerModes;
39
+ /**
40
+ *
41
+ * @param {LoggerModeNames} newValue Sets the logger mode of the current instance.
42
+ */
43
+ setCurrentMode(newValue: LoggerModeNames): void;
44
+ private _isLogTypeAllowedInCurrentMode;
45
+ /**
46
+ * A log type that doesn't necessarily need to be looked at by the end user.
47
+ * This can be any generic log that would be ignored in most logger modes except verbose.
48
+ *
49
+ * @param {string} title A short title for this log.
50
+ * @param {any} details Any optional detail that would be shown if this log was expanded in the console.
51
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
52
+ * was recorded from. For eg. Core and Ui can pass in different values for this
53
+ * paramater to make it easy to debug. If not provided, the default context would be used
54
+ * that was provided at the time of initialisation of this class.
55
+ */
56
+ info(title?: string, details?: any, contextOverride?: string | undefined): void;
57
+ /**
58
+ * A warning log type that let's the user know that some action that could be dangerous was just
59
+ * performed and might need attention.
60
+ *
61
+ * @param {string} title A short title for this log.
62
+ * @param {any} details Any optional detail that would be shown if this log was expanded in the console.
63
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
64
+ * was recorded from. For eg. Core and Ui can pass in different values for this
65
+ * paramater to make it easy to debug. If not provided, the default context would be used
66
+ * that was provided at the time of initialisation of this class.
67
+ */
68
+ warn(title?: string, details?: any, contextOverride?: string | undefined): void;
69
+ /**
70
+ * A critical error log type that let's the user know that some action that was unexpected and required immediate attention.
71
+ *
72
+ * @param {string} title A short title for this log.
73
+ * @param {any} details Any optional detail that would be shown if this log was expanded in the console.
74
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
75
+ * was recorded from. For eg. Core and Ui can pass in different values for this
76
+ * paramater to make it easy to debug. If not provided, the default context would be used
77
+ * that was provided at the time of initialisation of this class.
78
+ */
79
+ error(title?: string, details?: any, contextOverride?: string | undefined): void;
80
+ /**
81
+ * A table log type that can show an object in an organised manner within the console.
82
+ * This is primarily for the visual purposes and doesn't provide any additional functionality
83
+ * that other log types cannot provide.
84
+ *
85
+ * @param {string} title A short title for this log.
86
+ * @param {any} details Any optional detail that would be shown if this log was expanded in the console.
87
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
88
+ * was recorded from. For eg. Core and Ui can pass in different values for this
89
+ * paramater to make it easy to debug. If not provided, the default context would be used
90
+ * that was provided at the time of initialisation of this class.
91
+ * @param {LogTypes} logType A
92
+ */
93
+ table(title?: string, details?: any, contextOverride?: string | undefined, logType?: LogTypes): void;
94
+ /**
95
+ * Begins an expanded group with the browser's console window.
96
+ * NOTE: Please remember to close this group once done using EpigraphLogger.groupEnd();
97
+ *
98
+ * @param {string} title A short title for this group.
99
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
100
+ * was recorded from. For eg. Core and Ui can pass in different values for this
101
+ * paramater to make it easy to debug. If not provided, the default context would be used
102
+ * that was provided at the time of initialisation of this class.
103
+ * @param {LogTypes} logType A group can implictly of any log type, by default it is of type
104
+ * info but this parameter allows the user to override this.
105
+ * @returns {void}
106
+ */
107
+ group(title: string, contextOverride?: string | undefined, logType?: LogTypes): void;
108
+ /**
109
+ * Begins a collapsed group with the browser's console window.
110
+ * NOTE: Please remember to close this group once done using EpigraphLogger.groupEnd();
111
+ *
112
+ * @param {string} title A short title for this group.
113
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
114
+ * was recorded from. For eg. Core and Ui can pass in different values for this
115
+ * paramater to make it easy to debug. If not provided, the default context would be used
116
+ * that was provided at the time of initialisation of this class.
117
+ * @param {LogTypes} logType A group can implictly of any log type, by default it is of type
118
+ * info but this parameter allows the user to override this.
119
+ * @returns {void}
120
+ */
121
+ groupCollapsed(title: string, contextOverride?: string | undefined, logType?: LogTypes): void;
122
+ /**
123
+ * Similar to the console.groupEnd(). Useful for ending either a group or
124
+ * groupCollapse that was initialised by this logger.
125
+ *
126
+ * @returns {void}
127
+ */
128
+ groupEnd(): void;
18
129
  }
19
130
  export { EpigraphLogger };