1
0
mirror of https://git.stamm.me/OpenServer/NodeLogging.git synced 2024-11-24 04:19:24 +00:00
Go to file
2018-11-04 20:34:36 +01:00
out Fixing wrong version 2018-10-29 09:10:56 +01:00
src Fixing error on getCallerFromExisting when invalid error 2018-11-04 20:34:36 +01:00
.editorconfig Adding initialization on first write 2018-09-28 10:05:10 +02:00
.gitignore removing yarn.lock from git 2018-05-12 18:51:04 +02:00
package.json Fixing wrong version 2018-10-29 09:10:56 +01:00
readme.md Fixing markdown syntax error in readme 2018-10-05 20:41:13 +02:00
tsconfig.json First Commit 2017-08-23 16:45:03 +02:00

Simple node logging module, that supports terminal coloring and writing to files

Getting Started


const Logging = require("@hibas123/nodelogging").Logging;

Logging.log("Hello there");

There are different Logging levels, that also apply terminal coloring:

Logging.debug("Debug message")
Logging.log("Log message")
Logging.warning("Warning")
Logging.error(new Error("To less creativity"))
Logging.error("Just an simple message as error")
Logging.errorMessage("Nearly the same as error")

All Logging types except the simple error take as many arguments as you want. These will be joined with spaces and serialized with the node util.inspect function.

Setup

NodeLogging can work without any configuration, but it may be useful to change the log output folder.

Todo so you are capable of creating own instances of the LoggingBase class

   const CustomLogging = new LoggingBase({
      name: "custom",
      logfile: "./logs/test.log",
      errorfile: "/var/log/custom.err",
      console_out: false
   });

The name property prefixes the console output with the name. Also if no logfile or errorfile is created the following standard values are used:

./logs/all.{name}.log ./logs/error.{name}.log

To not use any logfiles just set the values to null.

License

MIT

Copyright (c) 2018 Fabian Stamm

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.