How to use @google-cloud/logging-winston - 3 common examples

To help you get started, we’ve selected a few @google-cloud/logging-winston examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Khan / react-render-server / src / logging.js View on Github external
function getTransports(isDev) {
    const transports = [];
    if (!isDev) {
        transports.push(new StackdriverTransport());
    }

    if (process.env.NODE_ENV === "test") {
        // During testing, we just dump logging to a stream.
        // This isn't used for anything at all right now, but we could use
        // it for snapshot testing with some updates at some point.
        const sink = new stream.Writable({write: () => {}});
        // This is a hack to make our writable stream work $FlowFixMe
        sink._write = sink.write;
        transports.push(
            new winston.transports.Stream({
                format: getFormatters(isDev),
                stream: sink,
            }),
        );
    } else {
github decentralized-identity / github-did / packages / api / src / lib / winston.js View on Github external
const winston = require('winston');

// Imports the Google Cloud client library for Winston
const { LoggingWinston } = require('@google-cloud/logging-winston');

const projectId = 'github-did';
const loggingWinston = new LoggingWinston({ projectId });

// Create a Winston logger that streams to Stackdriver Logging
// Logs will be written to: "projects/YOUR_PROJECT_ID/logs/winston_log"
const logger = winston.createLogger({
  level: 'info',
  transports: [
    new winston.transports.Console(),
    // Add Stackdriver Logging
    loggingWinston,
  ],
});

logger.stream = {
  write(message) {
    logger.info(message);
  },
github google / hangouts-chat-bot-cloud-function-nodejs-example / src / logger.js View on Github external
* 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.
 */

const {createLogger, format, transports} = require('winston');
const {LoggingWinston} = require('@google-cloud/logging-winston');

const logger = createLogger({
  format: format.simple(),
  level: 'debug',
  transports: [new transports.Console()],
});

if ('environment' in process.env && process.env.environment === 'production') {
  logger.add(new LoggingWinston());
}

module.exports = logger;

@google-cloud/logging-winston

Cloud Logging transport for Winston

Apache-2.0
Latest version published 9 months ago

Package Health Score

77 / 100
Full package analysis

Popular @google-cloud/logging-winston functions