0.0.54 • Published 8 years ago

roip-logger v0.0.54

Weekly downloads
62
License
-
Repository
github
Last release
8 years ago

RoIP Logger Module

Environment

  • LOG_LEVEL: (optional: default 'debug') debug, info, notice, warning, error, crit, alert, emerg. Production deployments should typically use 'info' level.

Console Log Configuration

  • LOG_CONSOLE_ENABLED: (optional: defaults to true) Set to true or yes, Enables file console transport.

File Log Configuration

  • LOG_FILE_ENABLED: (optional: defaults to true) Set to true or yes, Enables file logging transport.
  • LOG_FILE_PATH: (optional: default cwd/log/#{NODE_ENV}.log) Path for log file.

Syslog Configuration

Syslog can be enabled by setting LOG_SYSLOG_ENABLED environment variable. All other parameters are optional.

  • LOG_SYSLOG_ENABLED: (optional: defaults to 'false') Set to true or yes, Enables syslog logging transport.
  • LOG_SYSLOG_HOST: (optional: defaults to 'localhost') Syslog host
  • LOG_SYSLOG_PORT: (optional: defaults to 514) Syslog port
  • LOG_SYSLOG_PATH: (optional: defaults to null) Syslog path
  • LOG_SYSLOG_APP_ID: (optional: defaults to null) Syslog APP ID
  • LOG_SYSLOG_LOCALHOST: (optional: defaults to 'localhost') localhost as reported to syslog
  • LOG_SYSLOG_PROTOCOL: (optional: defaults to udp4) Syslog protocol (Values: udp,unix,tcp)
  • LOG_SYSLOG_TYPE: (optional: defaults to 'BSD') Syslog type
  • LOG_SYSLOG_FACILITY: (optional: defaults to 'local0') Syslog facility
  • LOG_SYSLOG_PID: (optional: defaults to process.pid) Process ID for reporting to syslog
  • LOG_SYSLOG_APP_NAME: (optional: defaults to process.title) Process title for reporting to syslog

Get Started

Configure package.json

{
  ...
  "dependencies": {
    "roip-logger": "git+ssh://git@github.com:OnCircle/node-logger.git"
  },
}

Examples:

# Start using logger module:
logger = require "roip-logger"

logger.debug("Message", obj1)
logger.debug("Message", obj1, "and here", obj3)
logger.error(err)
logger.error("Error is here:", err)
logger.warning("warning is here")
logger.warning("warning is here", err)
logger.info("some info message")
logger.emerg("something really bad happened")
logger.log("info", "aaaa", "bbb")
logger.log("debug", "aaaa", "bbb")

# Error logging with stack trace
logger.error(err)
logger.error("Caught some error:", err)
logger.warning("Caught some error:", err)
logger.info(err)

# Express Request Logger and Error Handler
# As a convenience, logger provides logger.expressRequestLogger and logger.expressErrorHandler
# Typically, expressRequestLogger is configured as the first middleware and expressErrorHandler is configured last.
app.disable('x-powered-by')
app.use logger.expressRequestLogger
app.use express.limit('1mb')
app.use express.timeout(5000)
app.use utils.allowCrossDomain
app.use express.methodOverride()
app.use express.bodyParser()
app.use app.router
app.use logger.expressErrorHandler

Additional Notes

  • You can log complete objects using logger. They will be dumped into the log using util.inspect().
  • You can send Error objects to the logger, they will be dumped in the log along with their stack traces (if present).
  • Messages longer than 1024 characters long will be truncated.
  • Generally, use logger.debug for debug messages during development. Production systems are set to "info" LOG_LEVEL, so any debug messages are not logged in production.

Execution Time Profiler

logger.profile "MyMegaAsyncOperation"
  # perform async operation
  logger.profile "MyMegaAsyncOperation"
0.0.54

8 years ago

0.0.53

9 years ago

0.0.52

9 years ago

0.0.51

9 years ago

0.0.50

9 years ago

0.0.49

9 years ago

0.0.48

9 years ago

0.0.47

9 years ago

0.0.46

9 years ago

0.0.45

9 years ago

0.0.44

9 years ago

0.0.43

9 years ago

0.0.42

9 years ago

0.0.41

9 years ago

0.0.40

9 years ago

0.0.39

9 years ago

0.0.38

9 years ago

0.0.37

9 years ago

0.0.36

9 years ago

0.0.35

10 years ago

0.0.34

10 years ago

0.0.33

10 years ago

0.0.32

10 years ago

0.0.31

10 years ago

0.0.30

10 years ago

0.0.29

10 years ago

0.0.28

10 years ago

0.0.27

10 years ago

0.0.26

10 years ago

0.0.24

10 years ago

0.0.23

10 years ago

0.0.22

10 years ago

0.0.21

10 years ago

0.0.20

10 years ago