本文整理匯總了TypeScript中log4js.getLogger函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getLogger函數的具體用法?TypeScript getLogger怎麽用?TypeScript getLogger使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了getLogger函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: errorLog
/**
* エラー內容をファイルに記述
* @param err {String}エラー內容
*/
static errorLog(err: string) {
//ログ出力設定ファイル、log_config.jsonの読み込み
log4js.configure(__dirname + '/log_config.json');
//ロガー取得
const errorLogger = log4js.getLogger('error');
errorLogger.error(err);
}
示例2: init
export function init(logger?, name = 'eip') {
if (logger) {
Logger = logger;
} else {
Logger = log4js.getLogger(`[${name}]`);
}
}
示例3: toArray
export function toArray(
callback: (doneChannels: ch.DoneChannel[]) => void ): void {
var logger = log4js.getLogger('app');
connect((err, db) => {
if (err != null) {
logger.error(err);
callback(null);
return;
}
db.collection('doneChannels', (err, collection) => {
if (err != null) {
logger.error(err);
callback(null);
return;
}
collection.find().sort({ end: -1 }).toArray((err, doneChannels: ch.DoneChannel[]) => {
if (err != null) {
logger.error(err);
callback(null);
return;
}
db.close(true);
callback(doneChannels);;
});
});
});
}
示例4: setup
function setup(app: express.Express) {
// View engine setup
app.set("views", path.join(__dirname, "/../views"));
app.set("view engine", "pug");
// uncomment after placing your favicon in /public
// app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
// Body parser setup
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
// Cookie parser setup
app.use(cookieParser());
// Log4js setup
app.use(log4js.connectLogger(log4js.getLogger("http"), { level: "auto" }));
// Passport setup when using
// app.use(setupedPassport.initialize());
// app.use(setupedPassport.session());
// Static dir setup
app.use(express.static(path.join(__dirname, "/../public")));
// Rooting setup
setupRoutes(app);
app.use((req, res, next) => {
const err = new HttpErrors.NotFound();
next(err);
});
app.use((err: Error, req, res, next) => {
const error = err as HttpErrors.HttpError;
res.status(error.status || 500);
const params = {
error: (process.env.NODE_ENV !== "production") ? error : null,
message: error.message
};
if (/^\/api/.test(req.originalUrl)) {
res.send(params);
} else {
res.render("error", params);
}
});
}
示例5: execute
function execute(ipaddress: string, port: number, rootIp:string, rootPort: number, dbAddress:string, publicPath: string) {
var logger = log4js.getLogger('app');
var app = express();
routes.rootServerIndexRepository = new rootserver.RootServerIndexRepository(rootIp, rootPort);
db.address = dbAddress;
app.configure(() => {
app.use((req, res, next) => {
logger.info([
req.headers['x-forwarded-for'] || req.client.remoteAddress,
new Date().toLocaleString(),
req.method,
req.url,
res.statusCode,
req.headers.referer || '-',
req.headers['user-agent'] || '-'
].join('\t'));
next();
});
app.use(express.favicon());
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(publicPath));
app.use((req, res) => {
res.sendfile(publicPath + '/partials/layout.html');
});
for (var dirPath in routes.routings) {
app.get(dirPath, routes.routings[dirPath]);
}
});
app.configure('development', () => {
app.use(express.logger('dev'));
app.use(express.errorHandler());
});
var server = http.createServer(app);
var ws = io.listen(server, { 'log level': 1 }, () => { });
ws.on('connection', socket => {
new routes.WebSocket(socket);
});
server.listen(port, ipaddress, null, function () {
logger.info("Express server listening on port " + port);
});
}
示例6: init
static init(config: any, app: express.Application): any {
var log4js: any = require('log4js');
log4js.configure('config/log4js_setting.json');
var logger = log4js.getLogger('app');
logger.setLevel(config.log.level); // ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF
logger.info('Logging start. ');
logger.info('Log Level:' + config.log.level);
app.use(log4js.connectLogger(logger, {
level: config.log.level
}));
return logger;
}
示例7: add
export function add(channel: ch.DoneChannel) {
var logger = log4js.getLogger('app');
connect((err, db) => {
if (err != null) {
logger.error(err);
return;
}
db.collection('doneChannels', (err, collection) => {
var old = new Date();
old.setDate(old.getDate() - 15);
collection.findAndRemove({
end: { $lt: old }
}, (err, line) => {// ついでに古いものを削除
if (err != null) {
logger.error(err);
}
if (line > 0) {
logger.info(line + ' doneChannel(s) deleted.');
}
}); // deleteは並列実行
collection.findAndRemove({
'channel.id': channel.channel.id,
end: { $gt: channel.begin }// > grater than 配信開始より後の時間に終了しているチャンネル
}, (err, line) => {// ネットワークトラブルとかで配信中にチャンネル終了扱いされちゃう場合に、直前の誤検出を削除する
if (err != null) {
logger.error(err);
}
if (line > 0) {
logger.info(line + ' doneChannel(s) deleted.');
}
}); // deleteは並列実行
collection.insert(channel, err => {
if (err != null) {
logger.error(err);
}
db.close(true);
});
});
});
}
示例8:
module.exports = (name = 'coc-nvim'): log4js.Logger => {
return log4js.getLogger(name)
}
示例9: express
import * as bodyParser from "body-parser";
import * as express from "express";
import * as http from "http";
import * as log4js from "log4js";
import * as morgan from "morgan"; // Logging middleware
import * as path from "path";
import * as uuid from "uuid";
import { default as configManager } from "./conf";
//import routes from "./routes";
log4js.configure(path.join(__dirname, "..", "log4js.config.json"));
const log = log4js.getLogger("main");
log.info("Initializing application...");
const app = express();
{ // Implement shutdown link. The application will exit by GET request to /shutdown
const isAllowedShutdowLink: boolean = configManager.getEnabled("server.shutdownlink");
if (isAllowedShutdowLink) {
log.info("Apply /shutdown link");
app.use(bodyParser.urlencoded({ extended: false }));
const shutdownKey = uuid.v1();
app.get("/shutdown", function (req: express.Request, res: express.Response): any {
return res
.header("Content-Type: text/html")
.send("<form method='POST'>"
+ "<input type='hidden' name='key' value='" + shutdownKey + "'>"
+ "<input type='submit' value='Shutdown'>"
示例10: requestHTTP
import http from 'http';
import log4js from 'log4js';
import PCPSocket from './applications/PCPSocket';
const logger = log4js.getLogger();
export {
PCPSocket,
};
export async function requestHTTP(options: http.RequestOptions) {
return new Promise<{ statusCode: number; socket: PCPSocket }>((resolve, reject) => {
if (options.headers == null) {
options.headers = {};
}
options.headers['x-peercast-pcp'] = 1;
// options.headers['x-peercast-pos'] = 0;
// options.headers['x-peercast-port'] = 7145;
try {
http.request(options, (res) => {
logger.debug('res');
resolve({
statusCode: res.statusCode!,
socket: new PCPSocket(res.socket, false),
});
}).end();
} catch (e) {
console.error(e.stack);
}
});
}