Tabnine Logo
BatfishLogger
Code IndexAdd Tabnine to your IDE (free)

How to use
BatfishLogger
in
org.batfish.common

Best Java code snippets using org.batfish.common.BatfishLogger (Showing top 20 results out of 315)

origin: batfish/batfish

private void serializeAwsConfigs(
  Path testRigPath, Path outputPath, ParseVendorConfigurationAnswerElement pvcae) {
 Map<Path, String> configurationData =
   readConfigurationFiles(testRigPath, BfConsts.RELPATH_AWS_CONFIGS_DIR);
 AwsConfiguration config;
 try (ActiveSpan parseAwsConfigsSpan =
   GlobalTracer.get().buildSpan("Parse AWS configs").startActive()) {
  assert parseAwsConfigsSpan != null; // avoid unused warning
  config = parseAwsConfigurations(configurationData, pvcae);
 }
 _logger.info("\n*** SERIALIZING AWS CONFIGURATION STRUCTURES ***\n");
 _logger.resetTimer();
 outputPath.toFile().mkdirs();
 Path currentOutputPath = outputPath.resolve(BfConsts.RELPATH_AWS_CONFIGS_FILE);
 _logger.debugf("Serializing AWS to \"%s\"...", currentOutputPath);
 serializeObject(config, currentOutputPath);
 _logger.debug("OK\n");
 _logger.printElapsedTime();
}
origin: batfish/batfish

boolean delNetwork(String networkName) {
 try {
  WebTarget webTarget =
    getTargetV2(Lists.newArrayList(CoordConstsV2.RSC_NETWORKS, networkName));
  Response response =
    webTarget
      .request(MediaType.APPLICATION_JSON)
      .header(CoordConstsV2.HTTP_HEADER_BATFISH_APIKEY, _settings.getApiKey())
      .header(CoordConstsV2.HTTP_HEADER_BATFISH_VERSION, Version.getVersion())
      .delete();
  if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) {
   _logger.errorf("delNetwork: Did not get OK response. Got: %s\n", response.getStatus());
   _logger.error(response.readEntity(String.class) + "\n");
   return false;
  }
  return true;
 } catch (Exception e) {
  _logger.errorf("Exception in delNetwork from %s for %s\n", _coordWorkMgrV2, networkName);
  _logger.error(Throwables.getStackTraceAsString(e) + "\n");
  return false;
 }
}
origin: batfish/batfish

private SortedMap<Path, String> readConfigurationFiles(Path testRigPath, String configsType) {
 _logger.infof("\n*** READING %s FILES ***\n", configsType);
 _logger.resetTimer();
 SortedMap<Path, String> configurationData = new TreeMap<>();
 Path configsPath = testRigPath.resolve(configsType);
 List<Path> configFilePaths = listAllFiles(configsPath);
 AtomicInteger completed =
   newBatch("Reading network configuration files", configFilePaths.size());
 for (Path file : configFilePaths) {
  _logger.debugf("Reading: \"%s\"\n", file);
  String fileTextRaw = CommonUtil.readFile(file.toAbsolutePath());
  String fileText = fileTextRaw + ((fileTextRaw.length() != 0) ? "\n" : "");
  configurationData.put(file, fileText);
  completed.incrementAndGet();
 }
 _logger.printElapsedTime();
 return configurationData;
}
origin: batfish/batfish

public void printElapsedTime() {
 double seconds = getElapsedTime(_timerCount);
 info("Time taken for this task: " + seconds + " seconds\n");
}
origin: batfish/batfish

public Set<Flow> computeCompositeNodOutput(
  List<CompositeNodJob> jobs, NodAnswerElement answerElement) {
 _logger.info("\n*** EXECUTING COMPOSITE NOD JOBS ***\n");
 _logger.resetTimer();
 Set<Flow> flows = new TreeSet<>();
 BatfishJobExecutor.runJobsInExecutor(
   _settings, _logger, jobs, flows, answerElement, true, "Composite NOD");
 _logger.printElapsedTime();
 return flows;
}
origin: batfish/batfish

private boolean showLogLevel(List<String> options, List<String> parameters) {
 if (!isValidArgument(options, parameters, 0, 0, 0, Command.SHOW_LOGLEVEL)) {
  return false;
 }
 _logger.outputf("Current client log level is %s\n", _logger.getLogLevelStr());
 return true;
}
origin: batfish/batfish

    .post(Entity.entity(multiPart, multiPart.getMediaType()));
_logger.debug(response.getStatus() + " " + response.getStatusInfo() + " " + response + "\n");
 _logger.debugf(
   "GetObject: Did not get an OK response for %s -> %s->%s\n",
   networkName, snapshotName, objectName);
_logger.errorf(
  "Exception in getObject from %s using (%s, %s)\n",
  _coordWorkMgr, snapshotName, objectName);
_logger.error(Throwables.getStackTraceAsString(e) + "\n");
return null;
origin: batfish/batfish

 public BatfishJob(Settings settings) {
  _settings = settings;
  _logger = new BatfishLogger(_settings.getLogLevel(), _settings.getTimestamp());
 }
}
origin: batfish/batfish

  _workHelper.getObject(wItem.getContainerName(), wItem.getTestrigName(), ansFileName);
if (downloadedAnsFile == null) {
 _logger.errorf("Failed to get answer file %s. (Was work killed?)\n", ansFileName);
} else {
 String answerString = CommonUtil.readFile(Paths.get(downloadedAnsFile));
   answerStringToPrint = answer.prettyPrint();
  } catch (IOException e) {
   _logger.warnf(
     "Using Json for pretty printing because could not deserialize response as %s: %s",
     Answer.class.getSimpleName(), e.getMessage());
 if (_logger.getLogLevel() >= BatfishLogger.LEVEL_DEBUG) {
  try {
   ObjectMapper reader = BatfishObjectMapper.mapper();
    _logger.errorf(
      "Original and recovered Json are different. Recovered = %s\n", newAnswerString);
   _logger.outputf("Could NOT deserialize Json to Answer: %s\n", e.getMessage());
if (_logger.getLogLevel() >= BatfishLogger.LEVEL_DEBUG) {
 _logger.output("---------------- Service Log --------------\n");
 String logFileName = wItem.getId() + BfConsts.SUFFIX_LOG_FILE;
 String downloadedFileStr =
  _logger.errorf("Failed to get log file %s\n", logFileName);
  return false;
 } else {
origin: batfish/batfish

String baseUrl = String.format("%s://%s", protocol, _mainSettings.getServiceBindHost());
URI baseUri = UriBuilder.fromUri(baseUrl).port(_mainSettings.getServicePort()).build();
_mainLogger.debug(String.format("Starting server at %s\n", baseUri));
ResourceConfig rc = new ResourceConfig(Service.class).register(new JettisonFeature());
if (_mainSettings.getTracingEnable()) {
   _mainLogger.errorf(
     "Parent process monitoring is not supported on Windows. We'll live without it.");
  } else {
       PARENT_CHECK_INTERVAL_MS,
       TimeUnit.MILLISECONDS);
   SignalHandler handler = signal -> _mainLogger.infof("BFS: Ignoring signal %s\n", signal);
   Signal.handle(new Signal("INT"), handler);
 _mainLogger.error(msg);
 System.exit(1);
} catch (Exception ex) {
 String stackTrace = Throwables.getStackTraceAsString(ex);
 _mainLogger.error(stackTrace);
 System.exit(1);
origin: batfish/batfish

/**
 * Returns a {@link Container Container} that contains information of '{@code networkName}',
 * returns null if network '{@code networkName}' does not exist or the api key that is using has
 * no access to the network
 */
@Nullable
Container getNetwork(String networkName) {
 try {
  WebTarget webTarget =
    getTargetV2(Lists.newArrayList(CoordConstsV2.RSC_NETWORKS, networkName));
  Response response =
    webTarget
      .request(MediaType.APPLICATION_JSON)
      .header(CoordConstsV2.HTTP_HEADER_BATFISH_APIKEY, _settings.getApiKey())
      .header(CoordConstsV2.HTTP_HEADER_BATFISH_VERSION, Version.getVersion())
      .get();
  _logger.debug(response.getStatus() + " " + response.getStatusInfo() + " " + response + "\n");
  if (response.getStatus() != Response.Status.OK.getStatusCode()) {
   _logger.errorf("getNetwork: Did not get OK response. Got: %s\n", response.getStatus());
   _logger.error(response.readEntity(String.class) + "\n");
   return null;
  }
  String containerStr = response.readEntity(String.class);
  return BatfishObjectMapper.mapper().readValue(containerStr, Container.class);
 } catch (Exception e) {
  _logger.errorf("Exception in getNetwork from %s for %s\n", _coordWorkMgrV2, networkName);
  _logger.error(Throwables.getStackTraceAsString(e) + "\n");
  return null;
 }
}
origin: batfish/batfish

private void printWorkStatusResponse(
  Pair<WorkStatusCode, String> response, boolean unconditionalPrint) {
 if (unconditionalPrint || _logger.getLogLevel() >= BatfishLogger.LEVEL_INFO) {
  WorkStatusCode status = response.getFirst();
  _logger.outputf("status: %s\n", status);
   task = BatfishObjectMapper.mapper().readValue(response.getSecond(), Task.class);
  } catch (IOException e) {
   _logger.errorf("Could not deserialize task object: %s\n", e);
   return;
   _logger.outputf(".... no task information\n");
   return;
    _logger.outputf(".... %s\n", batches.get(i));
   } else {
    _logger.debugf(".... %s\n", batches.get(i));
   _logger.outputf(".... %s: %s\n", task.getTerminated(), status);
origin: batfish/batfish

private void unsetTestrig(boolean doDelta) {
 if (doDelta) {
  _currDeltaTestrig = null;
  _logger.info("Reference snapshot is now unset\n");
 } else {
  _currTestrig = null;
  _logger.info("Current snapshot is now unset\n");
 }
}
origin: batfish/batfish

private synchronized int executeUpdate(PreparedStatement update) {
 int triesLeft = MAX_DB_TRIES;
 String updateString = update.toString();
 while (triesLeft > 0) {
  triesLeft--;
  try {
   _logger.debugf("Executing SQL update: %s\n", updateString);
   return update.executeUpdate();
  } catch (SQLException e) {
   _logger.errorf("SQLException while executing query '%s': %s", updateString, e.getMessage());
   _logger.errorf("Tries left = %d\n", triesLeft);
   if (triesLeft > 0) {
    try {
     if (!_dbConn.isValid(DB_VALID_CHECK_TIMEOUT_SECS)) {
      openDbConnection();
     }
    } catch (SQLException e1) {
     return 0;
    }
   }
  }
 }
 return 0;
}
origin: batfish/batfish

private void checkProcessCommandErrorMessage(
  Command command, String[] parameters, String expected) throws Exception {
 Client client = new Client(new String[] {"-runmode", "gendatamodel"});
 File tempFile = _folder.newFile("writer");
 FileWriter writer = new FileWriter(tempFile);
 client._logger = new BatfishLogger("output", false);
 String[] args = ArrayUtils.addAll(new String[] {command.commandName()}, parameters);
 assertFalse(client.processCommand(args, writer));
 assertThat(client.getLogger().getHistory().toString(500), equalTo(expected));
 writer.close();
}
origin: batfish/batfish

 @FormDataParam(CoordConsts.SVC_KEY_NETWORK_NAME) String networkName) {
try {
 _logger.infof("WMS:listSnapshots %s %s\n", apiKey, networkName);
   _logger.warnf(
     "Error listing snapshot %s in network %s: %s",
     networkName, snapshot, Throwables.getStackTraceAsString(e));
 _logger.errorf(
   "WMS:listSnapshots exception for apikey:%s in network:%s; exception:%s",
   apiKey, networkName, Throwables.getStackTraceAsString(e));
origin: batfish/batfish

@Override
public boolean isValidWorkApiKey(String apiKey) {
 Users allUsers = loadUsers();
 boolean validUser = allUsers.users.stream().anyMatch(u -> apiKey.equals(u.apikey));
 _logger.infof("Authorizer: %s is %s valid API key\n", apiKey, validUser ? "a" : "NOT a");
 return validUser;
}
origin: batfish/batfish

private boolean processCommand(String command) {
 String line = command.trim();
 if (line.length() == 0 || line.startsWith("#")) {
  return true;
 }
 _logger.debugf("Doing command: %s\n", line);
 String[] words = line.split("\\s+");
 return processCommand(words, null);
}
origin: batfish/batfish

private void saveSolverInput(Expr expr) {
 // synchronize to avoid z3 concurrency bugs.
 // use NodJob to synchronize with any other similar writers.
 synchronized (NodJob.class) {
  Path nodPath =
    _settings
      .getActiveTestrigSettings()
      .getBasePath()
      .resolve(
        String.format(
          "solverInput-%s-%d.smt2", Instant.now(), Thread.currentThread().getId()));
  try (FileWriter writer = new FileWriter(nodPath.toFile())) {
   writer.write(expr.toString());
  } catch (IOException e) {
   _logger.warnf("Error saving Nod program to file: %s", Throwables.getStackTraceAsString(e));
  }
 }
}
origin: batfish/batfish

 @Override
 public void run() {
  try {
   org.batfish.main.Driver.main(argArray, _logger);
  } catch (Exception e) {
   _logger.errorf(
     "Initialization of batfish failed with args: %s\nExceptionMessage: %s\n",
     Arrays.toString(argArray), e.getMessage());
  }
 }
};
org.batfish.commonBatfishLogger

Most used methods

  • <init>
  • debugf
  • errorf
  • info
  • error
  • infof
  • warnf
  • debug
  • getLogLevel
  • getLogLevelStr
  • output
  • append
  • output,
  • append,
  • getHistory,
  • isActive,
  • setLogLevel,
  • warn,
  • close,
  • getElapsedTime,
  • getPrintStream,
  • getRotatedLogFilename

Popular in Java

  • Finding current android device location
  • getApplicationContext (Context)
  • addToBackStack (FragmentTransaction)
  • onRequestPermissionsResult (Fragment)
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now