@allthings/cloud-toolkit 1.2.0 → 1.3.0-dev.1

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/dist/lib.cjs.js CHANGED
@@ -4,6 +4,7 @@ var clientLambda = require('@aws-sdk/client-lambda');
4
4
  var clientSsm = require('@aws-sdk/client-ssm');
5
5
  var aws = require('@aws-sdk/client-ses');
6
6
  var nodemailer = require('nodemailer');
7
+ var winston = require('winston');
7
8
 
8
9
  function _interopNamespaceDefault(e) {
9
10
  var n = Object.create(null);
@@ -158,8 +159,38 @@ const ses = (fromEmailAddress, userConfig) => {
158
159
  };
159
160
  };
160
161
 
162
+ const logger = (config) => {
163
+ const loggerConfig = {
164
+ defaultMeta: {
165
+ ...config.defaultLogInformation,
166
+ deploymentStage: config.deploymentStage,
167
+ service: config.service,
168
+ },
169
+ format: winston.format.combine(winston.format.timestamp({
170
+ format: 'DD-MM-YYYY HH:mm:ss',
171
+ }), winston.format.json()),
172
+ };
173
+ if (config.datadogApiKey && config.host) {
174
+ const httpOptions = {
175
+ headers: { 'DD-API-KEY': config.datadogApiKey },
176
+ host: config.host,
177
+ port: 443,
178
+ ssl: true,
179
+ };
180
+ return winston.createLogger({
181
+ ...loggerConfig,
182
+ transports: [new winston.transports.Http(httpOptions)],
183
+ });
184
+ }
185
+ return winston.createLogger({
186
+ ...loggerConfig,
187
+ transports: [new winston.transports.Console()],
188
+ });
189
+ };
190
+
161
191
  exports.DEFAULT_PARAMETER_STORE_CLIENT_CONFIG = DEFAULT_CLIENT_CONFIG$1;
162
192
  exports.DEFAULT_SES_CLIENT_CONFIG = DEFAULT_CLIENT_CONFIG;
163
193
  exports.lambda = lambda;
194
+ exports.logger = logger;
164
195
  exports.parameterStore = parameterStore;
165
196
  exports.ses = ses;
package/dist/lib.esm.js CHANGED
@@ -2,6 +2,7 @@ import { LambdaClient, InvokeCommand } from '@aws-sdk/client-lambda';
2
2
  import { SSMClient, GetParametersCommand, GetParameterCommand } from '@aws-sdk/client-ssm';
3
3
  import * as aws from '@aws-sdk/client-ses';
4
4
  import { createTransport } from 'nodemailer';
5
+ import { format, createLogger, transports } from 'winston';
5
6
 
6
7
  const DEFAULT_AWS_CONFIGURATION = {
7
8
  region: 'eu-central-2',
@@ -137,4 +138,33 @@ const ses = (fromEmailAddress, userConfig) => {
137
138
  };
138
139
  };
139
140
 
140
- export { DEFAULT_CLIENT_CONFIG$1 as DEFAULT_PARAMETER_STORE_CLIENT_CONFIG, DEFAULT_CLIENT_CONFIG as DEFAULT_SES_CLIENT_CONFIG, lambda, parameterStore, ses };
141
+ const logger = (config) => {
142
+ const loggerConfig = {
143
+ defaultMeta: {
144
+ ...config.defaultLogInformation,
145
+ deploymentStage: config.deploymentStage,
146
+ service: config.service,
147
+ },
148
+ format: format.combine(format.timestamp({
149
+ format: 'DD-MM-YYYY HH:mm:ss',
150
+ }), format.json()),
151
+ };
152
+ if (config.datadogApiKey && config.host) {
153
+ const httpOptions = {
154
+ headers: { 'DD-API-KEY': config.datadogApiKey },
155
+ host: config.host,
156
+ port: 443,
157
+ ssl: true,
158
+ };
159
+ return createLogger({
160
+ ...loggerConfig,
161
+ transports: [new transports.Http(httpOptions)],
162
+ });
163
+ }
164
+ return createLogger({
165
+ ...loggerConfig,
166
+ transports: [new transports.Console()],
167
+ });
168
+ };
169
+
170
+ export { DEFAULT_CLIENT_CONFIG$1 as DEFAULT_PARAMETER_STORE_CLIENT_CONFIG, DEFAULT_CLIENT_CONFIG as DEFAULT_SES_CLIENT_CONFIG, lambda, logger, parameterStore, ses };