@adaas/a-utils 0.1.15 → 0.1.17
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.
- package/LICENSE +10 -19
- package/README.md +74 -18
- package/dist/index.d.mts +270 -58
- package/dist/index.d.ts +270 -58
- package/dist/index.js +323 -103
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +324 -103
- package/dist/index.mjs.map +1 -1
- package/examples/{channel-examples.ts → A-Channel-examples.ts} +2 -2
- package/examples/{command-examples.ts → A-Command-examples.ts} +47 -45
- package/examples/A-Logger-examples.ts +308 -0
- package/examples/config.ts +1 -1
- package/package.json +45 -34
- package/src/lib/A-Command/A-Command.constants.ts +49 -13
- package/src/lib/A-Command/A-Command.entity.ts +21 -15
- package/src/lib/A-Command/A-Command.types.ts +2 -35
- package/src/lib/A-Config/A-Config.container.ts +3 -3
- package/src/lib/A-Config/components/ConfigReader.component.ts +4 -6
- package/src/lib/A-Logger/A-Logger.component.ts +369 -130
- package/src/lib/A-Logger/A-Logger.constants.ts +69 -0
- package/src/lib/A-Logger/A-Logger.env.ts +27 -0
- package/src/lib/A-Logger/A-Logger.types.ts +3 -0
- package/src/lib/A-Logger/README.md +383 -0
- package/src/lib/A-Manifest/A-Manifest.types.ts +1 -2
- package/src/lib/A-Memory/A-Memory.context.ts +1 -1
- package/tests/A-Command.test.ts +26 -26
- package/tests/A-Logger.test.ts +520 -0
- package/tests/A-Memory.test.ts +5 -5
- package/tests/A-Polyfill.test.ts +3 -2
package/LICENSE
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
Copyright 2025 ADAAS YAZILIM LİMİTED ŞİRKETİ
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
a copy of this software and associated documentation files (the
|
|
7
|
-
'Software'), to deal in the Software without restriction, including
|
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
-
the following conditions:
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|

|
|
7
|
-

|
|
8
7
|

|
|
9
8
|
|
|
10
|
-

|
|
11
10
|

|
|
12
11
|

|
|
13
12
|

|
|
@@ -249,32 +248,82 @@ const configLoader = new A_ConfigLoader();
|
|
|
249
248
|
|
|
250
249
|
### A-Logger
|
|
251
250
|
|
|
252
|
-
A
|
|
251
|
+
A sophisticated logging component with advanced formatting, scope-based organization, and configurable output levels for ADAAS applications.
|
|
253
252
|
|
|
254
253
|
**Basic Usage:**
|
|
255
254
|
```typescript
|
|
256
255
|
import { A_Logger } from '@adaas/a-utils';
|
|
257
256
|
import { A_Scope } from '@adaas/a-concept';
|
|
258
257
|
|
|
259
|
-
const scope = new A_Scope({
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
258
|
+
const scope = new A_Scope({ name: 'MyService' });
|
|
259
|
+
const logger = new A_Logger(scope);
|
|
260
|
+
|
|
261
|
+
// Basic logging with colors
|
|
262
|
+
logger.log('Application started');
|
|
263
|
+
logger.log('green', 'Operation successful');
|
|
264
|
+
logger.warning('Resource usage high');
|
|
265
|
+
logger.error('Database connection failed');
|
|
266
|
+
|
|
267
|
+
// Object logging with formatting
|
|
268
|
+
const user = { id: 1, name: 'John', active: true };
|
|
269
|
+
logger.log('blue', 'User data:', user);
|
|
270
|
+
|
|
271
|
+
// Multi-argument logging
|
|
272
|
+
logger.log('green',
|
|
273
|
+
'Processing complete:',
|
|
274
|
+
'Records:', 150,
|
|
275
|
+
'Errors:', 2,
|
|
276
|
+
'Success rate:', '98.7%'
|
|
277
|
+
);
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**Advanced Features:**
|
|
281
|
+
```typescript
|
|
282
|
+
// Error handling with context
|
|
283
|
+
try {
|
|
284
|
+
throw new Error('Database timeout');
|
|
285
|
+
} catch (error) {
|
|
286
|
+
logger.error('Operation failed:', error, 'Context:', {
|
|
287
|
+
userId: '123',
|
|
288
|
+
operation: 'update'
|
|
289
|
+
});
|
|
290
|
+
}
|
|
263
291
|
|
|
264
|
-
|
|
292
|
+
// Log level filtering (via A_LOGGER_LEVEL env var)
|
|
293
|
+
// Levels: debug, info, warn, error, all
|
|
294
|
+
process.env.A_LOGGER_LEVEL = 'warn'; // Only warnings and errors
|
|
265
295
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
296
|
+
// Scope alignment - all messages align consistently
|
|
297
|
+
const services = [
|
|
298
|
+
new A_Logger(new A_Scope({ name: 'API' })),
|
|
299
|
+
new A_Logger(new A_Scope({ name: 'DatabaseConnectionPool' })),
|
|
300
|
+
new A_Logger(new A_Scope({ name: 'Auth' }))
|
|
301
|
+
];
|
|
270
302
|
```
|
|
271
303
|
|
|
272
|
-
**Features:**
|
|
273
|
-
-
|
|
274
|
-
-
|
|
275
|
-
-
|
|
276
|
-
-
|
|
277
|
-
-
|
|
304
|
+
**Key Features:**
|
|
305
|
+
- ✅ **Scope-based Formatting** - Consistent message alignment regardless of scope name length
|
|
306
|
+
- ✅ **9 Terminal Colors** - green, blue, red, yellow, gray, magenta, cyan, white, pink
|
|
307
|
+
- ✅ **Object Pretty-printing** - JSON formatting with proper indentation
|
|
308
|
+
- ✅ **Error Handling** - Special formatting for A_Error and standard Error objects
|
|
309
|
+
- ✅ **Log Level Filtering** - Configurable filtering (debug, info, warn, error, all)
|
|
310
|
+
- ✅ **Performance Optimized** - Efficient handling of large objects and rapid logging
|
|
311
|
+
- ✅ **Multi-line Support** - Proper alignment for complex multi-argument logs
|
|
312
|
+
- ✅ **Timestamp Integration** - High-precision timestamps (MM:SS:mmm format)
|
|
313
|
+
|
|
314
|
+
**Output Examples:**
|
|
315
|
+
```
|
|
316
|
+
[API ] |15:42:123| Operation successful
|
|
317
|
+
[DatabaseConnectionPool] |15:42:124| Connection established
|
|
318
|
+
[Auth ] |15:42:125| User authenticated: {"id":1,"name":"John"}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
**Log Levels:**
|
|
322
|
+
- `debug` - Shows all messages
|
|
323
|
+
- `info` - Shows info, warning, and error messages
|
|
324
|
+
- `warn` - Shows warning and error messages only
|
|
325
|
+
- `error` - Shows error messages only
|
|
326
|
+
- `all` - Shows all messages (default)
|
|
278
327
|
|
|
279
328
|
---
|
|
280
329
|
|
|
@@ -552,3 +601,10 @@ Additional environment variables may be required by specific components like A-C
|
|
|
552
601
|
- [Report Issues](https://github.com/ADAAS-org/adaas-a-utils/issues)
|
|
553
602
|
- [Become Future Creator](https://sso.adaas.org)
|
|
554
603
|
---
|
|
604
|
+
|
|
605
|
+
## License
|
|
606
|
+
|
|
607
|
+
This project is licensed under the [Apache License 2.0](LICENSE).
|
|
608
|
+
|
|
609
|
+
© 2025 ADAAS YAZILIM LİMİTED ŞİRKETİ All rights reserved.
|
|
610
|
+
All original code and concepts are the intellectual property of ADAAS YAZILIM LİMİTED ŞİRKETİ
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { A_Fragment, A_Error, A_Component, A_TYPES__Error_Serialized, A_TYPES__Entity_Serialized,
|
|
2
|
-
import { A_TYPES__Container_Constructor } from '@adaas/a-concept/dist/src/global/A-Container/A-Container.types';
|
|
1
|
+
import { A_Fragment, A_Error, A_Component, A_TYPES__Error_Serialized, A_TYPES__Entity_Serialized, A_Entity, A_Scope, A_TYPES__ConceptENVVariables, A_TYPES__Fragment_Constructor, A_Container, A_Feature, A_TYPES__Component_Constructor, A_TYPES__Entity_Constructor, A_TYPES__Container_Constructor } from '@adaas/a-concept';
|
|
3
2
|
|
|
4
3
|
declare enum A_ChannelFeatures {
|
|
5
4
|
/**
|
|
@@ -492,32 +491,69 @@ declare class A_ChannelError extends A_Error {
|
|
|
492
491
|
get context(): A_ChannelRequest | undefined;
|
|
493
492
|
}
|
|
494
493
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
ABSTRACTIONS = "a-command-abstractions"
|
|
499
|
-
}
|
|
494
|
+
/**
|
|
495
|
+
* A-Command Statuses
|
|
496
|
+
*/
|
|
500
497
|
declare enum A_CONSTANTS__A_Command_Status {
|
|
498
|
+
/**
|
|
499
|
+
* Command has been created but not yet initialized
|
|
500
|
+
*/
|
|
501
501
|
CREATED = "CREATED",
|
|
502
|
+
/**
|
|
503
|
+
* Command is initializing
|
|
504
|
+
*/
|
|
502
505
|
INITIALIZATION = "INITIALIZATION",
|
|
506
|
+
/**
|
|
507
|
+
* Command has been initialized
|
|
508
|
+
*/
|
|
503
509
|
INITIALIZED = "INITIALIZED",
|
|
510
|
+
/**
|
|
511
|
+
* Command is compiling
|
|
512
|
+
*/
|
|
504
513
|
COMPILATION = "COMPILATION",
|
|
514
|
+
/**
|
|
515
|
+
* Command is compiled
|
|
516
|
+
*/
|
|
505
517
|
COMPILED = "COMPILED",
|
|
518
|
+
/**
|
|
519
|
+
* Command is executing
|
|
520
|
+
*/
|
|
506
521
|
IN_PROGRESS = "IN_PROGRESS",
|
|
522
|
+
/**
|
|
523
|
+
* Command has completed successfully
|
|
524
|
+
*/
|
|
507
525
|
COMPLETED = "COMPLETED",
|
|
526
|
+
/**
|
|
527
|
+
* Command has failed
|
|
528
|
+
*/
|
|
508
529
|
FAILED = "FAILED"
|
|
509
530
|
}
|
|
510
531
|
/**
|
|
511
532
|
* A-Command Lifecycle Features
|
|
512
533
|
*/
|
|
513
|
-
declare enum
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
534
|
+
declare enum A_CommandFeatures {
|
|
535
|
+
/**
|
|
536
|
+
* Allows to extend initialization logic and behavior
|
|
537
|
+
*/
|
|
538
|
+
onInit = "onInit",
|
|
539
|
+
/**
|
|
540
|
+
* Allows to extend compilation logic and behavior
|
|
541
|
+
*/
|
|
542
|
+
onCompile = "onCompile",
|
|
543
|
+
/**
|
|
544
|
+
* Allows to extend execution logic and behavior
|
|
545
|
+
*/
|
|
546
|
+
onExecute = "onExecute",
|
|
547
|
+
/**
|
|
548
|
+
* Allows to extend completion logic and behavior
|
|
549
|
+
*/
|
|
550
|
+
onComplete = "onComplete",
|
|
551
|
+
/**
|
|
552
|
+
*
|
|
553
|
+
*/
|
|
554
|
+
onFail = "onFail"
|
|
519
555
|
}
|
|
520
|
-
type A_CONSTANTS__A_Command_Event =
|
|
556
|
+
type A_CONSTANTS__A_Command_Event = keyof typeof A_CommandFeatures;
|
|
521
557
|
|
|
522
558
|
/**
|
|
523
559
|
* Command constructor type
|
|
@@ -569,30 +605,6 @@ type A_TYPES__Command_Serialized<ParamsType extends Record<string, any> = Record
|
|
|
569
605
|
* Command listener type
|
|
570
606
|
*/
|
|
571
607
|
type A_TYPES__Command_Listener<InvokeType extends A_TYPES__Command_Init = A_TYPES__Command_Init, ResultType extends Record<string, any> = Record<string, any>, LifecycleEvents extends string = A_CONSTANTS__A_Command_Event> = (command?: A_Command<InvokeType, ResultType, LifecycleEvents>) => void;
|
|
572
|
-
/**
|
|
573
|
-
* Command meta type
|
|
574
|
-
*/
|
|
575
|
-
type A_TYPES__CommandMeta = {
|
|
576
|
-
[A_TYPES__CommandMetaKey.EXTENSIONS]: A_Meta<{
|
|
577
|
-
/**
|
|
578
|
-
* Where Key the regexp for what to apply the extension
|
|
579
|
-
* A set of container names or a wildcard, or a regexp
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
* Where value is the extension instructions
|
|
583
|
-
*/
|
|
584
|
-
[Key: string]: A_TYPES__FeatureExtendDecoratorMeta[];
|
|
585
|
-
}>;
|
|
586
|
-
case: any;
|
|
587
|
-
[A_TYPES__CommandMetaKey.FEATURES]: A_Meta<{
|
|
588
|
-
/**
|
|
589
|
-
* Where Key is the name of the feature
|
|
590
|
-
*
|
|
591
|
-
* Where value is the list of features
|
|
592
|
-
*/
|
|
593
|
-
[Key: string]: A_TYPES__FeatureDefineDecoratorMeta;
|
|
594
|
-
}>;
|
|
595
|
-
};
|
|
596
608
|
|
|
597
609
|
declare class A_Command<InvokeType extends A_TYPES__Command_Init = A_TYPES__Command_Init, ResultType extends Record<string, any> = Record<string, any>, LifecycleEvents extends string | A_CONSTANTS__A_Command_Event = A_CONSTANTS__A_Command_Event> extends A_Entity<InvokeType, A_TYPES__Command_Serialized<InvokeType, ResultType>> {
|
|
598
610
|
/**
|
|
@@ -841,31 +853,231 @@ declare class A_Config<T extends Array<string | A_TYPES__ConceptENVVariables[num
|
|
|
841
853
|
set(property: T[number] | A_TYPES__ConceptENVVariables[number], value: any): any;
|
|
842
854
|
}
|
|
843
855
|
|
|
856
|
+
declare const A_LoggerEnvVariables: {
|
|
857
|
+
/**
|
|
858
|
+
* Sets the log level for the logger
|
|
859
|
+
*
|
|
860
|
+
* @example 'debug', 'info', 'warn', 'error'
|
|
861
|
+
*/
|
|
862
|
+
readonly A_LOGGER_LEVEL: "A_LOGGER_LEVEL";
|
|
863
|
+
/**
|
|
864
|
+
* Sets the default scope length for log messages
|
|
865
|
+
*
|
|
866
|
+
* @example 'A_LOGGER_DEFAULT_SCOPE_LENGTH'
|
|
867
|
+
*/
|
|
868
|
+
readonly A_LOGGER_DEFAULT_SCOPE_LENGTH: "A_LOGGER_DEFAULT_SCOPE_LENGTH";
|
|
869
|
+
};
|
|
870
|
+
type A_LoggerEnvVariablesType = (typeof A_LoggerEnvVariables)[keyof typeof A_LoggerEnvVariables][];
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* A_Logger - Advanced Logging Component with Scope-based Output Formatting
|
|
874
|
+
*
|
|
875
|
+
* This component provides comprehensive logging capabilities with:
|
|
876
|
+
* - Color-coded console output for different log levels
|
|
877
|
+
* - Scope-based message formatting with consistent alignment
|
|
878
|
+
* - Support for multiple data types (objects, errors, strings)
|
|
879
|
+
* - Configurable log levels for filtering output
|
|
880
|
+
* - Special handling for A_Error and native Error objects
|
|
881
|
+
* - Timestamp inclusion for better debugging
|
|
882
|
+
*
|
|
883
|
+
* Key Features:
|
|
884
|
+
* - **Scope Integration**: Uses A_Scope for consistent message prefixing
|
|
885
|
+
* - **Color Support**: Terminal color codes for visual distinction
|
|
886
|
+
* - **Object Formatting**: Pretty-prints JSON objects with proper indentation
|
|
887
|
+
* - **Error Handling**: Special formatting for A_Error and Error objects
|
|
888
|
+
* - **Log Level Filtering**: Configurable filtering based on severity
|
|
889
|
+
* - **Multi-line Support**: Proper alignment for multi-line messages
|
|
890
|
+
*
|
|
891
|
+
* @example
|
|
892
|
+
* ```typescript
|
|
893
|
+
* // Basic usage with dependency injection
|
|
894
|
+
* class MyService {
|
|
895
|
+
* constructor(@A_Inject(A_Logger) private logger: A_Logger) {}
|
|
896
|
+
*
|
|
897
|
+
* doSomething() {
|
|
898
|
+
* this.logger.log('Processing started');
|
|
899
|
+
* this.logger.log('blue', 'Custom color message');
|
|
900
|
+
* this.logger.warning('Something might be wrong');
|
|
901
|
+
* this.logger.error(new Error('Something failed'));
|
|
902
|
+
* }
|
|
903
|
+
* }
|
|
904
|
+
*
|
|
905
|
+
* // Advanced usage with objects
|
|
906
|
+
* logger.log('green', 'User data:', { id: 1, name: 'John' });
|
|
907
|
+
* logger.error(new A_Error('VALIDATION_FAILED', 'Invalid input data'));
|
|
908
|
+
* ```
|
|
909
|
+
*/
|
|
844
910
|
declare class A_Logger extends A_Component {
|
|
845
911
|
protected scope: A_Scope;
|
|
846
|
-
protected config?: A_Config<
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
912
|
+
protected config?: A_Config<A_LoggerEnvVariablesType> | undefined;
|
|
913
|
+
/**
|
|
914
|
+
* Terminal color codes for different log levels and custom styling
|
|
915
|
+
* These codes work with ANSI escape sequences for colored terminal output
|
|
916
|
+
*/
|
|
917
|
+
readonly COLORS: any;
|
|
918
|
+
/**
|
|
919
|
+
* Standard scope length for consistent formatting
|
|
920
|
+
* This ensures all log messages align properly regardless of scope name length
|
|
921
|
+
*/
|
|
922
|
+
private readonly STANDARD_SCOPE_LENGTH;
|
|
923
|
+
/**
|
|
924
|
+
* Initialize A_Logger with dependency injection
|
|
925
|
+
*
|
|
926
|
+
* @param scope - The current scope context for message prefixing
|
|
927
|
+
* @param config - Optional configuration for log level filtering
|
|
928
|
+
*/
|
|
929
|
+
constructor(scope: A_Scope, config?: A_Config<A_LoggerEnvVariablesType> | undefined);
|
|
930
|
+
/**
|
|
931
|
+
* Get the formatted scope length for consistent message alignment
|
|
932
|
+
* Uses a standard length to ensure all messages align properly regardless of scope name
|
|
933
|
+
*
|
|
934
|
+
* @returns The scope length to use for padding calculations
|
|
935
|
+
*/
|
|
859
936
|
get scopeLength(): number;
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
937
|
+
/**
|
|
938
|
+
* Get the formatted scope name with proper padding
|
|
939
|
+
* Ensures consistent width for all scope names in log output
|
|
940
|
+
*
|
|
941
|
+
* @returns Padded scope name for consistent formatting
|
|
942
|
+
*/
|
|
943
|
+
get formattedScope(): string;
|
|
944
|
+
/**
|
|
945
|
+
* Compile log arguments into formatted console output with colors and proper alignment
|
|
946
|
+
*
|
|
947
|
+
* This method handles the core formatting logic for all log messages:
|
|
948
|
+
* - Applies terminal color codes for visual distinction
|
|
949
|
+
* - Formats scope names with consistent padding
|
|
950
|
+
* - Handles different data types appropriately
|
|
951
|
+
* - Maintains proper indentation for multi-line content
|
|
952
|
+
*
|
|
953
|
+
* @param color - The color key to apply to the message
|
|
954
|
+
* @param args - Variable arguments to format and display
|
|
955
|
+
* @returns Array of formatted strings ready for console output
|
|
956
|
+
*/
|
|
957
|
+
compile(color: keyof typeof this.COLORS, ...args: any[]): Array<string>;
|
|
958
|
+
/**
|
|
959
|
+
* Format an object for display with proper JSON indentation
|
|
960
|
+
*
|
|
961
|
+
* @param obj - The object to format
|
|
962
|
+
* @param shouldAddNewline - Whether to add a newline prefix
|
|
963
|
+
* @param scopePadding - The padding string for consistent alignment
|
|
964
|
+
* @returns Formatted object string
|
|
965
|
+
*/
|
|
966
|
+
private formatObject;
|
|
967
|
+
/**
|
|
968
|
+
* Format a string for display with proper indentation
|
|
969
|
+
*
|
|
970
|
+
* @param str - The string to format
|
|
971
|
+
* @param shouldAddNewline - Whether to add a newline prefix
|
|
972
|
+
* @param scopePadding - The padding string for consistent alignment
|
|
973
|
+
* @returns Formatted string
|
|
974
|
+
*/
|
|
975
|
+
private formatString;
|
|
976
|
+
/**
|
|
977
|
+
* Determine if a log message should be output based on configured log level
|
|
978
|
+
*
|
|
979
|
+
* Log level hierarchy:
|
|
980
|
+
* - debug: Shows all messages
|
|
981
|
+
* - info: Shows info, warning, and error messages
|
|
982
|
+
* - warn: Shows warning and error messages only
|
|
983
|
+
* - error: Shows error messages only
|
|
984
|
+
* - all: Shows all messages (alias for debug)
|
|
985
|
+
*
|
|
986
|
+
* @param logMethod - The type of log method being called
|
|
987
|
+
* @returns True if the message should be logged, false otherwise
|
|
988
|
+
*/
|
|
989
|
+
protected shouldLog(logMethod: 'log' | 'warning' | 'error'): boolean;
|
|
990
|
+
/**
|
|
991
|
+
* General purpose logging method with optional color specification
|
|
992
|
+
*
|
|
993
|
+
* Supports two usage patterns:
|
|
994
|
+
* 1. log(message, ...args) - Uses default blue color
|
|
995
|
+
* 2. log(color, message, ...args) - Uses specified color
|
|
996
|
+
*
|
|
997
|
+
* @param color - Optional color key or the first message argument
|
|
998
|
+
* @param args - Additional arguments to log
|
|
999
|
+
*
|
|
1000
|
+
* @example
|
|
1001
|
+
* ```typescript
|
|
1002
|
+
* logger.log('Hello World');
|
|
1003
|
+
* logger.log('green', 'Success message');
|
|
1004
|
+
* logger.log('Processing user:', { id: 1, name: 'John' });
|
|
1005
|
+
* ```
|
|
1006
|
+
*/
|
|
1007
|
+
log(color: keyof typeof this.COLORS, ...args: any[]): void;
|
|
1008
|
+
log(...args: any[]): void;
|
|
1009
|
+
/**
|
|
1010
|
+
* Log warning messages with yellow color coding
|
|
1011
|
+
*
|
|
1012
|
+
* Use for non-critical issues that should be brought to attention
|
|
1013
|
+
* but don't prevent normal operation
|
|
1014
|
+
*
|
|
1015
|
+
* @param args - Arguments to log as warnings
|
|
1016
|
+
*
|
|
1017
|
+
* @example
|
|
1018
|
+
* ```typescript
|
|
1019
|
+
* logger.warning('Deprecated method used');
|
|
1020
|
+
* logger.warning('Rate limit approaching:', { current: 95, limit: 100 });
|
|
1021
|
+
* ```
|
|
1022
|
+
*/
|
|
864
1023
|
warning(...args: any[]): void;
|
|
1024
|
+
/**
|
|
1025
|
+
* Log error messages with red color coding
|
|
1026
|
+
*
|
|
1027
|
+
* Use for critical issues, exceptions, and failures that need immediate attention
|
|
1028
|
+
*
|
|
1029
|
+
* @param args - Arguments to log as errors
|
|
1030
|
+
* @returns void (for compatibility with console.log)
|
|
1031
|
+
*
|
|
1032
|
+
* @example
|
|
1033
|
+
* ```typescript
|
|
1034
|
+
* logger.error('Database connection failed');
|
|
1035
|
+
* logger.error(new Error('Validation failed'));
|
|
1036
|
+
* logger.error('Critical error:', error, { context: 'user-registration' });
|
|
1037
|
+
* ```
|
|
1038
|
+
*/
|
|
865
1039
|
error(...args: any[]): void;
|
|
1040
|
+
/**
|
|
1041
|
+
* Legacy method for A_Error logging (kept for backward compatibility)
|
|
1042
|
+
*
|
|
1043
|
+
* @deprecated Use error() method instead which handles A_Error automatically
|
|
1044
|
+
* @param error - The A_Error instance to log
|
|
1045
|
+
*/
|
|
866
1046
|
protected log_A_Error(error: A_Error): void;
|
|
1047
|
+
/**
|
|
1048
|
+
* Format A_Error instances for inline display within compiled messages
|
|
1049
|
+
*
|
|
1050
|
+
* Provides detailed formatting for A_Error objects including:
|
|
1051
|
+
* - Error code and message
|
|
1052
|
+
* - Description and stack trace
|
|
1053
|
+
* - Original error information (if wrapped)
|
|
1054
|
+
* - Documentation links (if available)
|
|
1055
|
+
*
|
|
1056
|
+
* @param error - The A_Error instance to format
|
|
1057
|
+
* @returns Formatted string ready for display
|
|
1058
|
+
*/
|
|
867
1059
|
protected compile_A_Error(error: A_Error): string;
|
|
1060
|
+
/**
|
|
1061
|
+
* Format standard Error instances for inline display within compiled messages
|
|
1062
|
+
*
|
|
1063
|
+
* Converts standard JavaScript Error objects into a readable JSON format
|
|
1064
|
+
* with proper indentation and stack trace formatting
|
|
1065
|
+
*
|
|
1066
|
+
* @param error - The Error instance to format
|
|
1067
|
+
* @returns Formatted string ready for display
|
|
1068
|
+
*/
|
|
868
1069
|
protected compile_Error(error: Error): string;
|
|
1070
|
+
/**
|
|
1071
|
+
* Generate timestamp string for log messages
|
|
1072
|
+
*
|
|
1073
|
+
* Format: MM:SS:mmm (minutes:seconds:milliseconds)
|
|
1074
|
+
* This provides sufficient precision for debugging while remaining readable
|
|
1075
|
+
*
|
|
1076
|
+
* @returns Formatted timestamp string
|
|
1077
|
+
*
|
|
1078
|
+
* @example
|
|
1079
|
+
* Returns: "15:42:137" for 3:42:15 PM and 137 milliseconds
|
|
1080
|
+
*/
|
|
869
1081
|
protected getTime(): string;
|
|
870
1082
|
}
|
|
871
1083
|
|
|
@@ -1064,7 +1276,7 @@ declare class A_ConfigError extends A_Error {
|
|
|
1064
1276
|
declare class ConfigReader extends A_Component {
|
|
1065
1277
|
protected polyfill: A_Polyfill;
|
|
1066
1278
|
constructor(polyfill: A_Polyfill);
|
|
1067
|
-
attachContext(container: A_Container, feature: A_Feature): Promise<void>;
|
|
1279
|
+
attachContext(container: A_Container, feature: A_Feature, config?: A_Config): Promise<void>;
|
|
1068
1280
|
initialize(config: A_Config): Promise<void>;
|
|
1069
1281
|
/**
|
|
1070
1282
|
* Get the configuration property by Name
|
|
@@ -1242,7 +1454,7 @@ declare class A_Memory<_MemoryType extends Record<string, any> = Record<string,
|
|
|
1242
1454
|
* @param requiredKeys
|
|
1243
1455
|
* @returns
|
|
1244
1456
|
*/
|
|
1245
|
-
|
|
1457
|
+
prerequisites(requiredKeys: Array<keyof _MemoryType>): Promise<boolean>;
|
|
1246
1458
|
/**
|
|
1247
1459
|
* Adds an error to the context
|
|
1248
1460
|
*
|
|
@@ -1403,4 +1615,4 @@ declare class A_Deferred<T> {
|
|
|
1403
1615
|
reject(reason?: any): void;
|
|
1404
1616
|
}
|
|
1405
1617
|
|
|
1406
|
-
export {
|
|
1618
|
+
export { type A_CONSTANTS__A_Command_Event, A_CONSTANTS__A_Command_Status, A_CONSTANTS__CONFIG_ENV_VARIABLES, A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY, A_Channel, A_ChannelError, A_ChannelFeatures, A_ChannelRequest, type A_ChannelRequestContext_Serialized, A_ChannelRequestStatuses, A_Command, A_CommandError, A_CommandFeatures, A_Config, A_ConfigError, A_ConfigLoader, A_Deferred, A_Logger, A_Manifest, A_ManifestChecker, A_ManifestError, A_Memory, A_Polyfill, A_Schedule, A_ScheduleObject, type A_TYPES__Command_Constructor, type A_TYPES__Command_Init, type A_TYPES__Command_Listener, type A_TYPES__Command_Serialized, type A_TYPES__ConfigContainerConstructor, type A_TYPES__ConfigENVVariables, A_TYPES__ConfigFeature, type A_UTILS_TYPES__ManifestQuery, type A_UTILS_TYPES__ManifestRule, type A_UTILS_TYPES__Manifest_AllowedComponents, type A_UTILS_TYPES__Manifest_ComponentLevelConfig, type A_UTILS_TYPES__Manifest_Init, type A_UTILS_TYPES__Manifest_MethodLevelConfig, type A_UTILS_TYPES__Manifest_Rules, type A_UTILS_TYPES__ScheduleObjectCallback, type A_UTILS_TYPES__ScheduleObjectConfig, ConfigReader, ENVConfigReader, FileConfigReader, type IbufferInterface, type IcryptoInterface, type Ifspolyfill, type IhttpInterface, type IhttpsInterface, type IpathInterface, type IprocessInterface, type IurlInterface };
|