How to use the createLogger function from winston

Find comprehensive JavaScript winston.createLogger code examples handpicked from public code repositorys.

43
44
45
46
47
48
49
50
51
52
53
    ],
    exceptionHandlers: [
      combinedLog
    ]
}
const logger = createLogger(winstonOptions)


if (isDev) {
  logger.info('Running the Electron app in dev mode.')
}
fork icon225
star icon731
watch icon32

+ 8 other calls in file

122
123
124
125
126
127
128
129
130
131
        formatForConsole
    ),
  });
}

/** @type {winston.Logger} */ const logger = winston.createLogger({
  level: logLevel,
  format: transformNonStringMessage(), // shared format for transports.
  transports: [mainLogTransport],
  exitOnError: false,
fork icon72
star icon140
watch icon33

+ 2 other calls in file

32
33
34
35
36
37
38
39
40
41
    return `${timestamp} [${label}] ${level}: ${removeLastLineBreak(message)} ${
        isNumber(durationMs) ? `| ${durationMs} ms`: ''}`
}

// Winston logger configuration
const logger = winston.createLogger({
    level: 'info',
    transports: [
        // Configures the log file
        new winston.transports.File({
fork icon25
star icon84
watch icon18

+ 7 other calls in file

10
11
12
13
14
15
16
17
18
19
20
// Define the CoreCommandRouter class
module.exports = CoreCommandRouter;
function CoreCommandRouter (server) {
  metrics.time('CommandRouter');


  this.logger = winston.createLogger({
    format: winston.format.simple(),
    transports: [
      new (winston.transports.Console)({level: 'verbose'})
    ]
fork icon28
star icon21
watch icon4

6
7
8
9
10
11
12
13
14
15
16
const util = require("util");
const config = require("config");
const getParams = require("get-parameter-names");
const { createLogger, format, transports } = require("winston");


const logger = createLogger({
  level: config.LOG_LEVEL,
  transports: [
    new transports.Console({
      format: format.combine(format.colorize(), format.simple()),
fork icon44
star icon17
watch icon25

+ 4 other calls in file

9
10
11
12
13
14
15
16
17
18
19
var diskCache = true;
var variant = 'none';
const { v4: uuidv4 } = require('uuid');


var winston = require('winston');
var logger = winston.createLogger({
  format: winston.format.simple(),
  transports: [
    new (winston.transports.Console)(),
    new (winston.transports.File)({
fork icon28
star icon21
watch icon4

+ 4 other calls in file

6
7
8
9
10
11
12
13
14
15
16
17
const winston = require('winston');
const ssh2 = require('ssh2');
const gunzip = require('gunzip-stream');


const config = require('../../api/config');
const logger = winston.createLogger(config.logger.winston);
const db = require('../../api/models');


console.log("connecting to db");
db.init(function(err) {
fork icon9
star icon8
watch icon4

245
246
247
248
249
250
251
252
253
254
try {
    fs.truncateSync(logpath);
} catch (err) {
    console.log("failed to truncate.. maybe first time "+logpath);
}
rlogger = createLogger({
    format: combine(
        timestamp(),
        format.splat(),
        format.printf(info=>{
fork icon9
star icon8
watch icon4

124
125
126
127
128
129
130
131
132
133
134
        return `${date.toLocaleString()}.${mili} ${level}: ${message}`;
    },
);


// Winston instance
const logger = (module.exports = winston.createLogger({
    level: logLevel,
    transports: [new winston.transports.Console()],
    format: winston.format.combine(
        winston.format.timestamp(),
fork icon1
star icon8
watch icon2

+ 7 other calls in file

46
47
48
49
50
51
52
53
54
55
56
57
        // }),


        // new (winston.transports.File)({filename: path.join(logDir, '/log.txt')})
    ],
}
const logger = winston.createLogger(logConfiguration);


// If we're not in production then log to the `console`
// But this doesn't work - seeing no message in my vscode debug console during extension development?
if (process.env.NODE_ENV !== 'production') {
fork icon1
star icon2
watch icon0

161
162
163
164
165
166
167
168
169
170
171
        + '(?:$|>)';
  }
}


function createLogger() {
  return winston.createLogger({
    level: CONFIG.options.logLevel,
    format: winston.format.combine(
      winston.format.splat(),
      winston.format.timestamp(),
fork icon1
star icon1
watch icon1

+ 18 other calls in file

81
82
83
84
85
86
87
88
89
90
91


const logger = winston.createLogger({
  level: 'info',
  transports: [appError, appCombined]
});
const plogger = winston.createLogger({
  level: 'info',
  transports: [protocolsLogs]
});
const clogger = winston.createLogger({
fork icon1
star icon1
watch icon1

+ 59 other calls in file

8
9
10
11
12
13
14
15
16
17
18
19
20
const InviteRenderer = require("./InviteRenderer.js");
const InviteResolver = require("./InviteResolver");


const app = express();


const logger = winston.createLogger();


if (process.env.NODE_ENV === "production") {
    logger.add(new winston.transports.Console({ level: process.env.LOGGING_LEVEL || "silly" }));
} else {
fork icon0
star icon1
watch icon0

25
26
27
28
29
30
31
32
33
34
35
36
    debug: process.env.NODE_ENV !== 'production',
    release: process.env.SENTRY_RELEASE,
    normalizeDepth: 5,
};


const winstonLogger = createLogger({
    transports: winstonTransports,
});


function getFunctionCaller(func) {
fork icon0
star icon3
watch icon210

+ 4 other calls in file

52
53
54
55
56
57
58
59
60
61
 */
exports.loggerFactory = function loggerFactory(logFileDirectory, type) {
    const consoleLogLevel = getLogLevel()
    const filePathParts = logFileDirectory.split('/')
    addColors(customLevels.colors)
    return createLogger({
        levels: customLevels.levels,
        format: combine(
            splat(),
            timestamp(),
fork icon0
star icon1
watch icon1

13
14
15
16
17
18
19
//       to use JSON format, with logging correlation.
if (!otelEnabled) {
	loggerOptions.format = winston.format.cli();
}


module.exports = winston.createLogger(loggerOptions);
fork icon0
star icon0
watch icon0

+ 4 other calls in file

125
126
127
128
129
130
131
132
133
134
        : `${[info.timestamp]} ${info.level}: ${info.message}`
    )
  ),
  exitOnError: false,
}
const logger = winston.createLogger(logConfiguration)
console.log('Logger created')
logger.info(
  `WickrLogger setup with Log Level: ${level}, Max File Size: ${maxSize}, and Max Number of files: ${maxFiles}`
)
fork icon0
star icon0
watch icon1

+ 15 other calls in file

2
3
4
5
6
7
8
9
10
11
12
// Danger is accessible globally
const match = require('micromatch');
const array = require('lodash/array');
const winston = require('winston');


const logger = module.exports = winston.createLogger({
  transports: [new winston.transports.Console()],
  format: winston.format.combine(
    winston.format.colorize({ all: true }),
    winston.format.simple()
fork icon0
star icon0
watch icon1

+ 15 other calls in file

21
22
23
24
25
26
27
28
29
30
31
    }
    return `${info.timestamp} ${info.level}:${padding} ${info.message}`
  })
)


const errorLogger = createLogger({
  level: 'error',
  format: logFormat,
  transports: [
    new transports.Console()
fork icon0
star icon0
watch icon1

+ 27 other calls in file

71
72
73
74
75
76
77
78
79
80
	info: 'white',
	warn: 'yellow',
	error: 'red'
});

const mainLogger = winston.createLogger({
	transports: [consoleTransport, fileTransport],
	levels: {
		trace: 4,
		debug: 3,
fork icon0
star icon0
watch icon1

+ 11 other calls in file