<commit_before><!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Hemera</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,700,800">
    <link rel="stylesheet" href="scripts/highlight/styles/github-gist.css">
    <link rel="stylesheet" href="stylesheets/styles.css">
</head>

<body>

    <!-- BEGIN NAVIGATION BAR -->
    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false"
                    aria-controls="navbar">
				<span class="sr-only">Toggle navigation</span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
			</button>
                <a class="navbar-brand" href="https://github.com/hemerajs/hemera"><img src="images/logo.png" width="32px" height="36px"></a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li class="active"><a href="index.html">Hemera</a></li>
                    <li><a href="https://github.com/hemerajs/hemera">GitHub</a></li>
                </ul>
            </div>
            <!--/.nav-collapse -->
        </div>
    </nav>
    <!-- END NAVIGATION BAR -->

    <div class="container body-container">
        <div class="main-content">
            <div class="row">

                <!-- BEGIN SIDEBAR -->
                <div class="col-sm-3 border-right section-left">
                    <div saveheight="1" class="sidebar-nav">
                        <h4>INTRODUCTION</h4>
                        <ul>
                            <li><a href="index.html"><span>Introduction</span></a></li>
                            <li><a href="getting-started.html"><span>Getting Started</span></a></li>
                            <li><a href="packages.html"><span>Packages</span></a></li>
                        </ul>

                        <h4>1. Basics</h4>
                        <ul>
                            <li><a href="1_request_reply.html"><span>Request & Reply</span></a></li>
                            <li><a href="1_pattern_matching.html"><span>Pattern matching</span></a></li>
                            <li><a href="1_pub_sub.html"><span>Publish & Subscribe</span></a></li>
                            <li><a href="1_payload_validation.html"><span>Payload validation</span></a></li>
                            <li><a href="1_middleware.html"><span>Middleware</span></a></li>
                            <li><a href="1_extension_points.html"><span>Extension Points</span></a></li>
                            <li><a href="1_logging.html" class="active"><span>Logging</span></a></li>
                            <li><a href="1_plugins.html"><span>Plugins</span></a></li>
                            <li><a href="1_metadata.html"><span>Metadata</span></a></li>
                            <li><a href="1_context.html"><span>Context</span></a></li>
                            <li><a href="1_delegate.html"><span>Delegate</span></a></li>
                        </ul>

                        <h4>2. ERROR HANDLING</h4>
                        <ul>
                            <li><a href="2_basic.html"><span>Basic</span></a></li>
                            <li><a href="2_timeout_errors.html"><span>Timeout errors</span></a></li>
                            <li><a href="2_fatal_errors.html"><span>Fatal errors</span></a></li>
                            <li><a href="2_error_propagation.html"><span>Error propagation</span></a></li>
                            <li><a href="2_transport_errors.html"><span>Listen on transport errors</span></a></li>
                            <li><a href="2_response_errors.html"><span>Listen on response errors</span></a></li>
                            <li><a href="2_custom_timeout.html"><span>Custom timeout per Act</span></a></li>
                        </ul>

                        <h4>3. TRACING</h4>
                        <ul>
                            <li><a href="3_life_cycle_events.html"><span>Life-cycle events</span></a></li>
                        </ul>

                        <h4>4. Internals</h4>
                        <ul>
                            <li><a href="4_overview.html"><span>Protocol</span></a></li>
                        </ul>

                        <h4>5. ADVANCED</h4>
                        <ul>
                            <li><a href="5_clustering.html"><span>Clustering</span></a></li>
                            <li><a href="5_api_versioning.html"><span>API Versioning</span></a></li>
                            <li><a href="5_nats_limits.html"><span>Nats limits & features</span></a></li>
                            <li><a href="5_testing.html"><span>Testing</span></a></li>
                            <li><a href="5_bridge.html"><span>Bridge</span></a></li>
                            <li><a href="5_nginx_integration_for_nats.html"><span>Nginx integration for NATS</span></a></li>
                            <li><a href="5_contributing.html"><span>Contributing</span></a></li>
                        </ul>

                        <h4>6. TOOLING</h4>
                        <ul>
                            <li><a href="6_monitoring.html"><span>Monitoring</span></a></li>
                            <li><a href="6_zipkin.html"><span>Zipkin</span></a></li>
                            <li><a href="6_cli.html"><span>CLI</span></a></li>
                        </ul>
                        <h4>7. BEST PRACTICE</h4>
                        <ul>
                            <li><a href="7_docker.html"><span>Docker</span></a></li>
                        </ul>

                    </div>
                </div>
                <!-- END SIDEBAR -->

                <!-- BEGIN CONTENT -->
                <div class="col-sm-9 border-left section-right">
                    <h1 class="section-header">Logging</h1>
                    <hr>

                    <p class="section-content">
                        This interface is everywhere available it's part of the core.
                        <pre>
<code class="javascript">
hemera.log.info("fooBar")
hemera.log.error("fooBar")

hemera.act({
  topic: "a",
  cmd: "a"
}, function (err, resp) {
 this.log.error(err.rootCause)
})
</code>
</pre>
                    </p>
                    <h4 class="section-h4">Custom logger</h4>
                    <p> Hemera used Pino logger by default but you can also use your own. Your custom logger have to support
                        following log levels.</p>
                    <pre>
<code class="javascript">
["info", "warn", "debug", "trace", "error", "fatal"]
</code>
</pre>
                    <h4 class="section-h4">Logging output example</h4>
                    <pre>
<code>
[2017-02-04T22:19:34.156Z] INFO (app/2056 on starptech): Connected!
[2017-02-04T22:19:34.160Z] INFO (app/2056 on starptech): ADD - ADDED
    topic: "math"
    cmd: "add"
[2017-02-04T22:19:34.163Z] INFO (app/2056 on starptech):
    outbound: {
      "id": "5ecdad999267f031109df50f653a7f46",
      "pattern": "a:1,b:2,cmd:add,topic:math"
    }
[2017-02-04T22:19:34.167Z] INFO (app/2056 on starptech):
    inbound: {
      "id": "5ecdad999267f031109df50f653a7f46",
      "duration": 0.003826,
      "pattern": "a:1,b:2,cmd:add,topic:math"
    }
</code>
                    </pre>

                </div>
                <!-- END CONTENT -->

            </div>
            <!-- /row --><commit_msg>improve logging section<commit_after><!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Hemera</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,700,800">
    <link rel="stylesheet" href="scripts/highlight/styles/github-gist.css">
    <link rel="stylesheet" href="stylesheets/styles.css">
</head>

<body>

    <!-- BEGIN NAVIGATION BAR -->
    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false"
                    aria-controls="navbar">
				<span class="sr-only">Toggle navigation</span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
			</button>
                <a class="navbar-brand" href="https://github.com/hemerajs/hemera"><img src="images/logo.png" width="32px" height="36px"></a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li class="active"><a href="index.html">Hemera</a></li>
                    <li><a href="https://github.com/hemerajs/hemera">GitHub</a></li>
                </ul>
            </div>
            <!--/.nav-collapse -->
        </div>
    </nav>
    <!-- END NAVIGATION BAR -->

    <div class="container body-container">
        <div class="main-content">
            <div class="row">

                <!-- BEGIN SIDEBAR -->
                <div class="col-sm-3 border-right section-left">
                    <div saveheight="1" class="sidebar-nav">
                        <h4>INTRODUCTION</h4>
                        <ul>
                            <li><a href="index.html"><span>Introduction</span></a></li>
                            <li><a href="getting-started.html"><span>Getting Started</span></a></li>
                            <li><a href="packages.html"><span>Packages</span></a></li>
                        </ul>

                        <h4>1. Basics</h4>
                        <ul>
                            <li><a href="1_request_reply.html"><span>Request & Reply</span></a></li>
                            <li><a href="1_pattern_matching.html"><span>Pattern matching</span></a></li>
                            <li><a href="1_pub_sub.html"><span>Publish & Subscribe</span></a></li>
                            <li><a href="1_payload_validation.html"><span>Payload validation</span></a></li>
                            <li><a href="1_middleware.html"><span>Middleware</span></a></li>
                            <li><a href="1_extension_points.html"><span>Extension Points</span></a></li>
                            <li><a href="1_logging.html" class="active"><span>Logging</span></a></li>
                            <li><a href="1_plugins.html"><span>Plugins</span></a></li>
                            <li><a href="1_metadata.html"><span>Metadata</span></a></li>
                            <li><a href="1_context.html"><span>Context</span></a></li>
                            <li><a href="1_delegate.html"><span>Delegate</span></a></li>
                        </ul>

                        <h4>2. ERROR HANDLING</h4>
                        <ul>
                            <li><a href="2_basic.html"><span>Basic</span></a></li>
                            <li><a href="2_timeout_errors.html"><span>Timeout errors</span></a></li>
                            <li><a href="2_fatal_errors.html"><span>Fatal errors</span></a></li>
                            <li><a href="2_error_propagation.html"><span>Error propagation</span></a></li>
                            <li><a href="2_transport_errors.html"><span>Listen on transport errors</span></a></li>
                            <li><a href="2_response_errors.html"><span>Listen on response errors</span></a></li>
                            <li><a href="2_custom_timeout.html"><span>Custom timeout per Act</span></a></li>
                        </ul>

                        <h4>3. TRACING</h4>
                        <ul>
                            <li><a href="3_life_cycle_events.html"><span>Life-cycle events</span></a></li>
                        </ul>

                        <h4>4. Internals</h4>
                        <ul>
                            <li><a href="4_overview.html"><span>Protocol</span></a></li>
                        </ul>

                        <h4>5. ADVANCED</h4>
                        <ul>
                            <li><a href="5_clustering.html"><span>Clustering</span></a></li>
                            <li><a href="5_api_versioning.html"><span>API Versioning</span></a></li>
                            <li><a href="5_nats_limits.html"><span>Nats limits & features</span></a></li>
                            <li><a href="5_testing.html"><span>Testing</span></a></li>
                            <li><a href="5_bridge.html"><span>Bridge</span></a></li>
                            <li><a href="5_nginx_integration_for_nats.html"><span>Nginx integration for NATS</span></a></li>
                            <li><a href="5_contributing.html"><span>Contributing</span></a></li>
                        </ul>

                        <h4>6. TOOLING</h4>
                        <ul>
                            <li><a href="6_monitoring.html"><span>Monitoring</span></a></li>
                            <li><a href="6_zipkin.html"><span>Zipkin</span></a></li>
                            <li><a href="6_cli.html"><span>CLI</span></a></li>
                        </ul>
                        <h4>7. BEST PRACTICE</h4>
                        <ul>
                            <li><a href="7_docker.html"><span>Docker</span></a></li>
                        </ul>

                    </div>
                </div>
                <!-- END SIDEBAR -->

                <!-- BEGIN CONTENT -->
                <div class="col-sm-9 border-left section-right">
                    <h1 class="section-header">Logging</h1>
                    <hr>

                    <p class="section-content">
                        Hemera used <a href="https://github.com/pinojs/pino">Pino</a> logger by default but you can also
                        use your own.
                        <h4 class="section-h4">Logging</h4>
                        <pre>
<code class="javascript">
hemera.log.info("fooBar")
hemera.log.error("fooBar")

hemera.act({
  topic: "a",
  cmd: "a"
}, function (err, resp) {
 this.log.error(err.rootCause)
})
</code>
</pre>
                    </p>
                    <h4 class="section-h4">Set log levels</h4>
                    <pre>
<code class="javascript">
const hemera = new Hemera(nats, {
  logLevel: "info"
})
</code>
</pre>
                    <h4 class="section-h4">Log level</h4>
                    <pre>
<code class="javascript">
["info", "warn", "debug", "trace", "error", "fatal"]
</code>
</pre>
                    <h4 class="section-h4">Logging output example</h4>
                    <pre>
<code>
[2017-02-04T22:19:34.156Z] INFO (app/2056 on starptech): Connected!
[2017-02-04T22:19:34.160Z] INFO (app/2056 on starptech): ADD - ADDED
    topic: "math"
    cmd: "add"
[2017-02-04T22:19:34.163Z] INFO (app/2056 on starptech):
    outbound: {
      "id": "5ecdad999267f031109df50f653a7f46",
      "pattern": "a:1,b:2,cmd:add,topic:math"
    }
[2017-02-04T22:19:34.167Z] INFO (app/2056 on starptech):
    inbound: {
      "id": "5ecdad999267f031109df50f653a7f46",
      "duration": 0.003826,
      "pattern": "a:1,b:2,cmd:add,topic:math"
    }
</code>
                    </pre>
                    <h4 class="section-h4">Use custom logger</h4>
                    <pre>
<code class="javascript">
class Logger {
  info (msg) {
    console.log(msg)
  }
}

const hemera = new Hemera(nats, {
  logLevel: "info",
  logger: new Logger()
})
</code>
</pre>

                </div>
                <!-- END CONTENT -->

            </div>
            <!-- /row -->
{'fraction_non_alphanumeric': 0.17693484245946772, 'fraction_numerical': 0.027837259100642397, 'mean_word_length': 1.5851652696504823, 'pattern_counts': {'":': 10, '<': 661, '<?xml version=': 0, '>': 661, 'https://': 11, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '467146', 'n_tokens_mistral': 5307, 'n_tokens_neox': 4846, 'n_words': 741}