Skip to content

Commit

Permalink
Removed useless imports and made some refactors.
Browse files Browse the repository at this point in the history
  • Loading branch information
marmos91 committed Apr 16, 2017
1 parent e055c54 commit 4039844
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
4 changes: 4 additions & 0 deletions gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const sourcemaps = require("gulp-sourcemaps");
const ts = require("gulp-typescript");
const remapIstanbul = require("remap-istanbul/lib/gulpRemapIstanbul");

/**
* @author Marco Moschettini
* @version 0.0.1
*/
@Gulpclass()
export class GulpFile
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "winston-decorator",
"version": "0.0.7",
"version": "0.0.8",
"description": "A decorator version of the winston logger written completely in Typescript.",
"scripts": {
"test": "node_modules/.bin/gulp tests"
Expand Down
18 changes: 8 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import * as winston from 'winston';
import {LoggerInstance} from 'winston';
import {type} from 'os';
import {Logger, LoggerOptions, LoggerInstance, transports} from 'winston';

/**
* Options interface for the logger decorator
* @interface
* @author Marco Moschettini Alessandro Petraro
* @version 0.0.1
* @version 0.0.8
*/
export interface DecoratorOptions
{
Expand All @@ -26,9 +24,9 @@ export interface DecoratorOptions
* @param settings {winston.LoggerOptions} see https://github.com/winstonjs/winston
* @param options {DecoratorOptions} (optional)
* @author Marco Moschettini Alessandro Petraro
* @version 0.0.1
* @version 0.0.8
*/
export function logger(settings?: winston.LoggerOptions | DecoratorOptions, options?: DecoratorOptions)
export function logger(settings?: LoggerOptions, options?: DecoratorOptions)
{
return function(target: any, key: string | symbol)
{
Expand All @@ -37,14 +35,14 @@ export function logger(settings?: winston.LoggerOptions | DecoratorOptions, opti
{
let label = (options && options.label) || (target.name || target.constructor.name);

let logger = new (winston.Logger)(settings);
logger.add(winston.transports.Console, {label});
let logger = new (Logger)(settings);
logger.add(transports.Console, {label});
target.constructor.prototype[key] = logger;
}
else
{
let logger = new (winston.Logger)(settings);
logger.add(winston.transports.File, {filename: '/dev/null'});
let logger = new (Logger)(settings);
logger.add(transports.File, {filename: '/dev/null'});
target.constructor.prototype[key] = logger;
}
}
Expand Down

0 comments on commit 4039844

Please sign in to comment.