This repository was archived by the owner on Mar 17, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +57
-1
lines changed
Expand file tree Collapse file tree 5 files changed +57
-1
lines changed Original file line number Diff line number Diff line change 1- 10.24
1+ 12
Original file line number Diff line number Diff line change 4343 "apollo-link-http" : " ^1.5.17" ,
4444 "async-lock" : " ^1.2.4" ,
4545 "aws-sdk" : " ^2.669.0" ,
46+ "az-bunyan" : " ^0.2.0-alpha.2" ,
4647 "bluebird" : " ^3.7.2" ,
4748 "bunyan" : " ^1.8.12" ,
4849 "bunyan-cloudwatch" : " ^2.2.0" ,
Original file line number Diff line number Diff line change @@ -17,6 +17,11 @@ module.exports = {
1717 LOG_CLOUDWATCH_LEVEL : 'error' ,
1818 LOG_CLOUDWATCH_GROUP_NAME : '' ,
1919 LOG_CLOUDWATCH_STREAM_NAME : '' ,
20+
21+ LOG_AZURETABLESTORAGE_ENALBE : false ,
22+ LOG_AZURETABLESTORAGE_LEVEL : 'error' ,
23+ LOG_AZURETABLESTORAGE_TABLENAME : 'sometableforlogs' ,
24+ LOG_AZURETABLESTORAGE_CONNECTIONSTRING : 'DefaultEndpointsProtocol=https;AccountName=storageAccountName;AccountKey=storageAccoutnKey;' ,
2025 } ,
2126 development : {
2227 LOG_STDOUT_ENABLE : false ,
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ const DebugStream = require('bunyan-debug-stream');
44const Slack = require ( 'bunyan-slack' ) ;
55const Teams = require ( 'bunyan-teams' ) ;
66const Cloudwatch = require ( 'bunyan-cloudwatch' ) ;
7+ const AzBunyan = require ( 'az-bunyan' ) ;
78
89const def = {
910 friendlyName : 'LoggerCreator' ,
@@ -123,6 +124,23 @@ const def = {
123124
124125 // -------------------------------------------------------------------------
125126
127+ // push to azure blob storage
128+ if ( configs . LOG_AZURETABLESTORAGE_ENALBE ) {
129+ streams . push ( AzBunyan . createTableStorageStream ( configs . LOG_AZURETABLESTORAGE_LEVEL , {
130+ connectionString : configs . LOG_AZURETABLESTORAGE_CONNECTIONSTRING ,
131+ tableName : configs . LOG_AZURETABLESTORAGE_TABLENAME
132+ } ) ) ;
133+ // streams.push({
134+ // level: configs.LOG_AZURETABLESTORAGE_LEVEL,
135+ // stream: AzBunyan.createTableStorageStream(configs.LOG_AZURETABLESTORAGE_LEVEL, {
136+ // connectionString: configs.LOG_AZURETABLESTORAGE_CONNECTIONSTRING,
137+ // tableName: configs.LOG_AZURETABLESTORAGE_TABLENAME
138+ // }),
139+ // });
140+ }
141+
142+ // -------------------------------------------------------------------------
143+
126144 // level of logs based on environment
127145 let level = 'info' ;
128146 if ( configs . environment === 'production' ) level = 'info' ;
Original file line number Diff line number Diff line change @@ -42,3 +42,35 @@ describe('test logger ringBuffer', () => {
4242 checkMethod ( 'warn' ) ;
4343 checkMethod ( 'error' ) ;
4444} ) ;
45+
46+ describe ( 'az bunyan test' , ( ) => {
47+ const checkMethod = ( method ) => {
48+ it ( `it produce to ringBuffer when put level: ${ method } ` , async ( ) => {
49+ const log = await createLogger ( {
50+ configs : {
51+ ...defaultConfig ,
52+ APP_NAME : 'jest' ,
53+
54+ LOG_AZURETABLESTORAGE_ENALBE : true ,
55+ LOG_AZURETABLESTORAGE_LEVEL : 'trace' ,
56+ LOG_AZURETABLESTORAGE_TABLENAME : 'na....logs' ,
57+ LOG_AZURETABLESTORAGE_CONNECTIONSTRING : 'D....indows.net' ,
58+ } ,
59+ } ) ;
60+
61+ // info
62+ log [ method ] ( `test for ${ method } ` ) ;
63+ expect ( log . ringBuffer . records [ 0 ] ) . toMatchObject ( {
64+ msg : expect . stringMatching ( new RegExp ( method , 'ig' ) ) ,
65+ } ) ;
66+
67+ expect ( log ) . toHaveProperty ( method ) ;
68+ expect ( log [ method ] ) . toBeInstanceOf ( Function ) ;
69+ } ) ;
70+ } ;
71+
72+ checkMethod ( 'trace' ) ;
73+ checkMethod ( 'info' ) ;
74+ checkMethod ( 'warn' ) ;
75+ checkMethod ( 'error' ) ;
76+ } ) ;
You can’t perform that action at this time.
0 commit comments