How to use the debug function from winston

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

winston.debug is a method provided by the Winston logging library that logs debug-level messages to the console or a file.

151
152
153
154
155
156
157
158
159
160
    return false;
}
const userDataRequestUri = `https://graph.facebook.com/${api_1.API_VERSION}/me?access_token=${accessToken}`;
const userDataResponse = yield gaxios.request({ method: "GET", url: userDataRequestUri });
if (userDataResponse.data.error && userDataResponse.data.error.message) {
    winston.debug("Failed oauthCheck because access token was expired or due to an error: " +
        userDataResponse.data.error.message);
    return false;
}
return true;
fork icon95
star icon47
watch icon68

+ 23 other calls in file

61
62
63
64
65
66
67
68
69
70
oauthUrl(redirectUri, encryptedPayload) {
    return __awaiter(this, void 0, void 0, function* () {
        // Step 2 of the oauth flow - user will be sent to this Salesforce url to consent to the login.
        // `redirectUri` in this case is the AH url to which Salesforce will send them *back*, along with an auth code.
        // Note the "payload" is what we generated in loginForm above and will just be passed back to us.
        winston.debug(`beginning oauth flow with redirect url: ${redirectUri}`);
        const actionCrypto = new Hub.ActionCrypto();
        const plaintext = yield actionCrypto
            .decrypt(encryptedPayload)
            .catch((err) => {
fork icon95
star icon47
watch icon68

+ 19 other calls in file

How does winston.debug work?

winston.debug is a method provided by the Winston logging library that allows you to log debug-level messages to the console or a file. To use winston.debug, you first need to create a Winston logger instance using the winston.createLogger() method, which returns a new logger object with various logging methods, including debug. Once you have created a logger instance, you can use the debug method to log a debug-level message. This method takes a message string as the first argument, and an optional object with metadata as the second argument. By default, winston.debug logs messages to the console using the Console transport. However, you can also configure Winston to log messages to a file or a remote logging service using other available transports. Here is an example of how to use winston.debug to log a debug-level message to the console: javascript Copy code {{{{{{{ const winston = require('winston'); const logger = winston.createLogger({ level: 'debug', format: winston.format.simple(), transports: [new winston.transports.Console()], }); logger.debug('Debug message'); In this example, we create a new Winston logger instance with the default Console transport, and set the logging level to "debug". We then use the debug method to log a debug-level message to the console with the message "Debug message". Overall, winston.debug provides a simple way to log debug-level messages to the console or a file, making it easier to debug and troubleshoot Node.js applications.

170
171
172
173
174
175
176
177
178
179
        }
        return response;
    }
    yield Promise.all(this.batchPromises);
    const successMessage = `Streaming upload complete. Sent ${this.numBatches} batches (batch size = ${BATCH_SIZE})`;
    winston.debug("info", successMessage);
    resp.success = true;
    resp.message = successMessage;
    return resp;
});
fork icon95
star icon47
watch icon68

+ 19 other calls in file

187
188
189
190
191
192
193
194
195
196
if (err && err.response && err.response.data &&
    err.response.data.error && err.response.data.error.message) {
    // Note: these can still leak access tokens if facebook replies with:
    // "400 bad request, here's what you sent me!". keep the logging at debug level
    winston.debug("Facebook error message was: " + err.response.data.error.message);
    winston.debug("Facebook user friendly message title was: " +
        err.response.data.error.error_user_title);
    winston.debug("Facebook user friendly message was: " +
        err.response.data.error.error_user_msg);
}
fork icon95
star icon47
watch icon68

+ 11 other calls in file

Ai Example

1
2
3
4
5
6
7
8
9
10
11
const winston = require("winston");

// Create a logger instance with the default Console transport
const logger = winston.createLogger({
  level: "debug",
  format: winston.format.simple(),
  transports: [new winston.transports.Console()],
});

// Log a debug message with some metadata
logger.debug("Debug message", { foo: "bar", baz: 42 });

In this example, we create a logger instance with the default Console transport and set the logging level to "debug". We then use the debug method to log a message with the string "Debug message" and some metadata. When run in a Node.js environment, this code will output a message to the console that looks something like this: css Copy code

59
60
61
62
63
64
65
66
67
68
        level: "debug",
        transports: [
            new (winston.transports.Console)(),
        ],
    });
    winston.debug("Debug Mode");
}
const port = process.env.PORT ? parseInt(process.env.PORT, 10) : 8080;
// Default to 0 to prevent Node from applying timeout to sockets
// Load balancers in front of the app may still timeout
fork icon95
star icon47
watch icon68

+ 7 other calls in file

65
66
67
68
69
70
71
72
73
      `${Settings.VIEWS_SERVE}/${view.id}/${view.description}`,
      'utf8'
    );
    res.send(help);
  } catch (e) {
    logger.debug(e);
    res.send(e.message);
  }
},
fork icon0
star icon1
watch icon0

+ 29 other calls in file

237
238
239
240
241
242
243
244
245
246
  var stats = fs.statSync(user_path);
} catch (e) {
  logger.debug('Updater: Folder not found!');
  let default_path = this._get_default_folder(language);
  try {
    logger.debug(
      `Updater: Copying default controller ${default_path}->${user_path}`
    );
    var fileNames = fs.readdirSync(default_path);
    fs.mkdirSync(user_path, { recursive: true });
fork icon0
star icon1
watch icon0

+ 29 other calls in file

59
60
61
62
63
64
65
66
67
68
  this.session.hardware.eventGenerator.addListener(socket);
}

disconnect(id) {
  try {
    logger.debug(`Disconnecting read only client ${id}`);
    this.socket.disconnect();
  } catch (e) {
    logger.debug("Can't disconnect read only client properly.");
  }
fork icon0
star icon1
watch icon0

+ 32 other calls in file

175
176
177
178
179
180
181
182
183
184
  redirectUrl = '/tickets'
}

req.logIn(user, function (err) {
  if (err) {
    winston.debug(err)
    return next(err)
  }

  return res.redirect(redirectUrl)
fork icon0
star icon0
watch icon1

+ 33 other calls in file

80
81
82
83
84
85
86
87
88
89
    });
}
function initializeSocketIO(s) {
    ioInstance = socketio(s);
    const initializeNamespace = (name, exec) => {
        if (debug) winston.debug('initializing socketIO', name);
        const newNamespace = ioInstance.of('/' + name);
        newNamespace.on('connection', (socket) => {
            socket.on('disconnect', () => {
                if (debug) winston.info(`Client ${socket.id} disconnected.`);
fork icon0
star icon0
watch icon1

+ 7 other calls in file

32
33
34
35
36
37
38
39
40
41
42
43
}




exports.searchmf = async (req, res) => {
    try {
        Logger.debug(req.query)
        let mf = req.query.mf
        let société = await retenueService.searchmf(mf)
        res.status(200).json(société)
    } catch (error) {
fork icon0
star icon0
watch icon0

+ 2 other calls in file

12
13
14
15
16
17
18
19
20
21
22
23




//---------------- Création de user ----------------------------------
exports.register = async (req, res, next) => {
    try {
        Logger.debug(req.body.name, req.body.login)
        let name = req.body.name
        let login = req.body.login
        let password = req.body.password
        let type = req.body.type
fork icon0
star icon0
watch icon0

+ 33 other calls in file

12
13
14
15
16
17
18
19
20
21
22
23
24
25






exports.register = async (data, filename) => {
    try {
        // Logger.debug("user to register : ", data)
        let found = await User.find({ login: data.user.login })


        if (!found || found.length <= 0) {
            let template = await Template.findAll()
fork icon0
star icon0
watch icon0

14
15
16
17
18
19
20
21
22
23
24
25
}




exports.createCompany = async (req, res) => {
    try {
        Logger.debug(req.body, req.file)
        let data = {
            name: req.body.name ?? undefined,
            address: req.body.address ?? undefined,
            telephone: req.body.telephone ?? undefined,
fork icon0
star icon0
watch icon0

+ 4 other calls in file

5
6
7
8
9
10
11
12
13
14
15
16
17






exports.register = async (req, res) => {
    try {
        // Logger.debug(req.body, req.file)
        let file
        let filename
        if (req.file) {
            req.file.originalname = req.file.originalname.split('.')[0] + '.PNG'
fork icon0
star icon0
watch icon0