mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2025-09-27 07:20:19 +00:00
Add files via upload
This commit is contained in:
71
website/functions/node_modules/@google-cloud/common/src/logger.js
generated
vendored
Normal file
71
website/functions/node_modules/@google-cloud/common/src/logger.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
/*!
|
||||
* Copyright 2016 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/*!
|
||||
* @module common/logger
|
||||
*/
|
||||
|
||||
const format = require('string-format-obj');
|
||||
const is = require('is');
|
||||
const logDriver = require('log-driver');
|
||||
|
||||
/**
|
||||
* The default list of log levels.
|
||||
* @type {string[]}
|
||||
*/
|
||||
const LEVELS = ['silent', 'error', 'warn', 'info', 'debug', 'silly'];
|
||||
|
||||
/**
|
||||
* Create a logger to print output to the console.
|
||||
*
|
||||
* @param {string=|object=} options - Configuration object. If a string, it is
|
||||
* treated as `options.level`.
|
||||
* @param {string=} options.level - The minimum log level that will print to the
|
||||
* console. (Default: `error`)
|
||||
* @param {Array.<string>=} options.levels - The list of levels to use. (Default:
|
||||
* logger.LEVELS)
|
||||
* @param {string=} options.tag - A tag to use in log messages.
|
||||
*/
|
||||
function logger(options) {
|
||||
if (is.string(options)) {
|
||||
options = {
|
||||
level: options,
|
||||
};
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
|
||||
return logDriver({
|
||||
levels: options.levels || LEVELS,
|
||||
|
||||
level: options.level || 'error',
|
||||
|
||||
format: function() {
|
||||
const args = [].slice.call(arguments);
|
||||
|
||||
return format('{level}{tag} {message}', {
|
||||
level: args.shift().toUpperCase(),
|
||||
tag: options.tag ? ':' + options.tag + ':' : '',
|
||||
message: args.join(' '),
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = logger;
|
||||
module.exports.LEVELS = LEVELS;
|
Reference in New Issue
Block a user