New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

yog-log

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yog-log - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

0

doc/odp-log.md

@@ -0,0 +0,0 @@ # Node Log方案调研

24

index.js

@@ -19,3 +19,2 @@ var fs = require('fs'),

3 : 'ACCESS_ERROR',
//应用日志等级 ODP格式

@@ -30,7 +29,8 @@ 1 : 'FATAL',

//模板文件地址,可以不填
if(opts['data_path']){
if(opts && opts['data_path']){
data_path = opts['data_path'];
}
//用户只需要填写log_path配置
if(opts['log_path']){
if(opts && opts['log_path']){
log_path = opts['log_path'];

@@ -45,3 +45,3 @@ }

'IS_ODP' : true,
'IS_OMP' : 1,
'IS_OMP' : 0,
'log_path': log_path,

@@ -184,4 +184,4 @@ 'access_log_path' : log_path + "/access",

this.params['COOKIE'] = req.headers['cookie'];
this.params['USER_AGENT'] = req.headers['user-agent'];
this.params['SERVER_ADDR'] = req.headers.host;
this.params['USER_AGENT'] = req.headers['user-agent'] ;
this.params['SERVER_ADDR'] = req.headers.host ;
this.params['SERVER_PROTOCOL'] = String(req.protocol).toUpperCase();

@@ -258,7 +258,7 @@ this.params['REQUEST_METHOD'] = req.method || "";

log_path = this.opts['use_sub_dir'] ?
(this.opts['log_path'] + "/" + this.opts['app']) : this.opts['app'];
(this.opts['log_path'] + "/" + this.opts['app']) : this.opts['log_path'] ;
logFile = prefix;
}
return log_path + "/" + logFile;
return log_path + "/" + logFile + ".log";
},

@@ -593,3 +593,3 @@

getParams : function(name){
if(this.params.hasOwnProperty(name) && this.params[name]!='undefined'){
if(this.params.hasOwnProperty(name) && this.params[name]!=undefined){
return this.params[name];

@@ -605,3 +605,3 @@ }

getCookie : function(name){
var match = this.getParams("COOKIE").match(new RegExp(name + '=([^;]+)'));
var match = String(this.getParams("COOKIE")).match(new RegExp(name + '=([^;]+)'));
if (match){

@@ -677,8 +677,8 @@ return match[1];

module.exports.getLogger = function(){
module.exports.getLogger = function(config){
if(process.domain && process.domain.logger){
return process.domain.logger;
}else{
return new Logger();
return new Logger(config);
}
};

@@ -0,0 +0,0 @@

{
"name": "yog-log",
"version": "0.0.3",
"version": "0.0.4",
"description": "yog logger",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -48,3 +48,3 @@ # Node Log 统计方案

//model或其他没有res的地方使用
var logger = Logger.getLogger();
var logger = Logger.getLogger(config); //不传递config走默认配置,配置说明见日志接口
logger.log('warning','msg');//or logger.warning('msg');

@@ -54,3 +54,23 @@

## 接口文档
### 应用日志等级
应用日志等级分为 `FATAL` 、`WARNING `、`NOTICE` 、 `TRACE`、`DEBUG`几个,可以配置线上日志等级来确定统计哪些日志。默认为16,即统计所有日志(具体可参考下面日志默认配置说明)。
### 日志统计接口
针对每个应用日志等级都有相应的接口。如fatal日志可以通过 `logger.log('fatal',{'stack':e,'msg':'error!'})`的方式统计;也可以通过`logger.fatal({'stack':e,'msg':'error!'})` 方式统计。其他几个等级一样。
如果是访问日志,对应的等级名称为`access`(正常访问)及`access_error`(异常访问404等),使用方式跟应用日志一样。默认通过中间件方式使用yog-log时将统计访问日志和301、404错误日志。错误日志默认单独存储。
**log(level,obj) 方法参数 :**
- level : 日志等级,同上
- obj: string或者object格式。如果是string,认为是错误消息。如果是object,请使用正确格式。正确格式为{'stack':e,'msg':'msg','errno':'010'},分别代表错误堆栈、错误消息、错误码。错误消息如果不填将使用错误堆栈的消息。
### 自定义配置
统计模块默认以中间件的形式且只有请求过来才会进行初始化,初始化后可以在model等地方直接获取到此实例。如果未进行初始化(没有请求)就想使用日志统计,请传递日志参数。日志配置项见下所示。
## 日志配置

@@ -57,0 +77,0 @@

@@ -0,0 +0,0 @@

@@ -9,6 +9,24 @@

var obj = util.gettimeofday();
console.log(obj);
var logId = (((obj['sec']*100000 + obj['usec']/10) & 0x7FFFFFFF) || 0x80000000);
console.log(logId);
console.log(logId);
Object.defineProperty(global, '__stack', {
get: function(){
var orig = Error.prepareStackTrace;
Error.prepareStackTrace = function(_, stack){ return stack; };
var err = new Error;
Error.captureStackTrace(err, arguments.callee);
var stack = err.stack;
Error.prepareStackTrace = orig;
return stack;
}
});
Object.defineProperty(global, '__line', {
get: function(){
return __stack[1].getLineNumber();
}
});
console.log(__line);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc