当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript winston.log函数代码示例

本文整理汇总了TypeScript中winston.log函数的典型用法代码示例。如果您正苦于以下问题:TypeScript log函数的具体用法?TypeScript log怎么用?TypeScript log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了log函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: logLevel

 private static logLevel(level : string, msg : string, user : User = undefined, room : Room = undefined) : void {
   if(user || room) {
     Winston.log(level, msg, {
       user : {
         userID : user ? user.userID : undefined,
         userName : user ? user.userName : undefined
       },
       room : {
         roomID : room ? room.roomID : undefined,
         userCount: room ? room.userCount : undefined
       }
     });
   }
   else {
     Winston.log(level, msg);
   }
 }
开发者ID:andwoo,项目名称:grouptube2,代码行数:17,代码来源:Logger.ts

示例2: function

            let logger = function (log: string) {
                assert(log.indexOf("Verbosity1") === -1);
                assert(log.indexOf("Verbosity3") === -1);

                if (log.indexOf("Verbosity2") !== -1) {
                    LoggingHelper.setVerbose(false);
                    winston.log("verbose", "Verbosity3");
                    winston.info("Verbosity4");
                }

                if (log.indexOf("Verbosity4") !== -1) {
                    done();
                }
            };
开发者ID:debmalya,项目名称:bst,代码行数:14,代码来源:logging-helper-test.ts

示例3: parseDate

function parseDate(input : string) : Date {
    function rangeError(type : string) {
        var errorMsg = "while parsing '" + input + "'. " + type + " number is not in the correct range. Line is ignored.";
        winston.log("error", errorMsg);
    }
    var splitted : number[] = input.split("/").map(Number);
    var now : Date = new Date();

    if (splitted.length != 3) {
        var errorMsg = "while parsing '" + input + "'. The date is incorrectly formed (not of the form #/#/#). Line is ignored.";
        winston.log("error", errorMsg);
        return null;
    }

    if (splitted.some(function(n) { // check if all numbers are not NaN
        return isNaN(n); 
    })) {
        var errorMsg = "while parsing '" + input + "'. Not all values are numbers. Line is ignored.";
        winston.log("error", errorMsg);
        return null;
    }

    if (splitted[0] < 1 || (splitted[1] == 2 && splitted[0] > 28) || (splitted[1] in [4, 6, 9, 11] && splitted[0] > 30) || splitted[0] > 31
           || (splitted[2] == now.getFullYear() && splitted[1] == now.getMonth() + 1 && splitted[0] > now.getDate())) { // check if date is of correct 
        rangeError("day");
    }
    if (splitted[1] < 1 || splitted[1] > 12 || (splitted[2] == now.getFullYear() && splitted[1] > now.getMonth() + 1)) { // check if month is in the correct range
        rangeError("month");
    }
    if (splitted[2] < 1901 || splitted[2] > new Date().getFullYear()) { // check if year is in the correct range
        rangeError("year");
    }
    var day = splitted[0];
    var month = splitted[1] - 1;
    var year = splitted[2];
    return new Date(year, month, day);
}
开发者ID:SimonGGit,项目名称:Softbank,代码行数:37,代码来源:ReadingCSV.ts

示例4: parseCSVTransaction

function parseCSVTransaction(values : string[]) {
    var date : Date = parseDate(values[0]);
    if (date === null) return null; // skip line if error while parsing;
    if (!(values[1] in personDict)) personDict[values[1]] = new Person(values[1]);
    if (!(values[2] in personDict)) personDict[values[2]] = new Person(values[2]);
    var origin : Person = personDict[values[1]];
    var to : Person = personDict[values[2]];
    var narrative : string = values[3];
    var amount : number = parseFloat(values[4]);
    if (isNaN(amount)) {
        var errorMsg = "while parsing: '" + values[4] + "' is not a number. Line is ignored";
        winston.log("error", errorMsg);
        return null; // skip line
    }
    return new Transaction(date, origin, to, narrative, amount);
}
开发者ID:SimonGGit,项目名称:Softbank,代码行数:16,代码来源:ReadingCSV.ts

示例5: loadCSV

function loadCSV(fileName : string) {
    var data : string[] = fs.readFileSync(fileName, "utf8", function(err, txt) {
        return txt;
    }).split("\n");

    for (var i = 1; i < data.length; i++) {
        var values : string[] = data[i].split(",");
        if (values.length != 5) {
            var errorMsg = "line number " + i + " in file '" + fileName + "': the line only contains " + values.length + " columns instead of 5. Line is ignored";
            winston.log("error", errorMsg);
            continue; // skip line
        }
        var transaction = parseCSVTransaction(values);
        if (transaction === null) continue; // skip this line
        handleTransaction(transaction);
    }
}
开发者ID:SimonGGit,项目名称:Softbank,代码行数:17,代码来源:ReadingCSV.ts

示例6:

        let server = app.listen(port, () => {
            let host: string = server.address().address;

            winston.log('info', 'listening at http://' + host + ':' + port);
        });
开发者ID:RELATO,项目名称:nestea,代码行数:5,代码来源:app.ts

示例7: require

let config    = require(__dirname + '/config/config.json')[env];

const app: express.Express = express();
const port: number = process.env.PORT || 3000;

let allModels;

/*
 * Use middleware to convert post data into json.
 * It puts request into post/get/put/patch req.body parameter
 */
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());

// Setting up our singleton...
winston.log('info', 'Environment: ' + env);
if (env === 'test') {
    allModels = models.modelCollector('TEST', 'root', 'netsucesso', {
        dialect: 'mysql',
        host: 'localhost'
    });
} else if (env === 'ci') {
    winston.log('info', 'at CI');
    allModels = models.modelCollector('circle_test', 'root', 'netsucesso', {
        dialect: 'mysql',
        host: 'localhost'
    });
} else if (env === 'development') {
    allModels = models.modelCollector('TEST', 'root', 'netsucesso', {
        dialect: 'mysql',
        host: 'localhost'
开发者ID:RELATO,项目名称:nestea,代码行数:31,代码来源:app.ts

示例8: rangeError

 function rangeError(type : string) {
     var errorMsg = "while parsing '" + input + "'. " + type + " number is not in the correct range. Line is ignored.";
     winston.log("error", errorMsg);
 }
开发者ID:SimonGGit,项目名称:Softbank,代码行数:4,代码来源:ReadingCSV.ts

示例9: require

import allModels = require('../../main/models');
import app = require('../../main/app');
import httpStatusCodes = require('../../main/constants/http-codes-const');

let agent = request.agent(app),
    orm,
    Book,
    bookId;

if (process.env.NODE_ENV === 'test') {
    orm = allModels.modelCollector('TEST', 'root', 'netsucesso', {
        host: 'localhost',
        dialect: 'mysql'
    });
} else if (process.env.NODE_ENV === 'ci') {
    winston.log('info', 'At CI');
    orm = allModels.modelCollector('circle_test', 'root', "netsucesso", {
        dialect: 'mysql',
        host: 'localhost'
    });
}
Book = orm.Book;

describe('Book Crud test', () => {
    it('Should allow a book to be poster and return a read and _id', (done) => {
        let bookPost = {
            title: 'carlos thought the',
            author: 'Carlangas',
            genre: 'History'
        };
开发者ID:RELATO,项目名称:nestea,代码行数:30,代码来源:book-crud-spec.ts


注:本文中的winston.log函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。