2
2
* Copyright (c) 2016-present, Alejandro Mantilla <@AlejoJamC>.
3
3
* All rights reserved.
4
4
*
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree or translated in the assets folder.
5
+ * This source code is licensed under the MIT license found in the LICENSE
6
+ * file in the root directory of this source tree or translated in the assets folder.
7
7
*/
8
8
9
9
/**
10
10
* Module dependencies
11
11
*/
12
-
13
- // TODO: evitar error si la carpeta logs no existe, crear la carpeta por codigo
14
12
var fs = require ( 'fs' ) ,
15
13
path = require ( 'path' ) ,
16
14
winston = require ( 'winston' ) ,
17
15
18
- filedebug = path . join ( __dirname , '..' , 'logs' , 'debug.log' ) ,
19
- filerror = path . join ( __dirname , '..' , 'logs' , 'error.log' ) ,
20
- fileinfo = path . join ( __dirname , '..' , 'logs' , 'info.log' ) ;
16
+ folderlogs = path . join ( __dirname , '..' , 'logs' ) ,
17
+
18
+ filedebug = path . join ( folderlogs , 'debug.log' ) ,
19
+ filerror = path . join ( folderlogs , 'error.log' ) ,
20
+ fileinfo = path . join ( folderlogs , 'info.log' ) ;
21
21
22
- // Activate winston emitter
22
+ /**
23
+ * Check if folder logs exists.
24
+ */
25
+ if ( ! ( fs . existsSync ( folderlogs ) ) ) {
26
+ fs . mkdirSync ( folderlogs ) ;
27
+ }
28
+
29
+ // Activate winston emitter.
23
30
winston . emitErrs = true ;
24
31
25
- // Remove the file, ignoring any errors
32
+ // Remove the file, ignoring any errors.
26
33
try {
27
34
fs . unlinkSync ( fileinfo ) ;
28
35
fs . unlinkSync ( filedebug ) ;
@@ -70,7 +77,6 @@ var logger = new (winston.Logger)({
70
77
} ) ;
71
78
72
79
/**
73
- * Export winston logger coniguration
80
+ * Export winston logger coniguration.
74
81
*/
75
-
76
- module . exports . Logger = logger ;
82
+ module . exports . logger = logger ;
0 commit comments